运维之路

centos下mysql备份脚本(备份数)

#*/30****sh/xxx/startReadMysqlData.sh>>/xxx/log.log#bakServer:pod6xxx.xxx.xxx.xxx#!/bin/bash#保存备份个数number=6#备份保存路径backup_dir=/root/dbbakServer/data#备份日志路径backLog_dir=/root/dbbakServer/log#日期dd=`date+%Y-%m-%d-%H-%M-%S`#工具tool=/app/mysql/bin/./mysqldump#用户名username=cmss_mysql#密码password=GSGpsfu5#第二目标服务器bakServer=xx.xxx.xxx.xxxxx#第二目标服务器文件存放bakServer_dir=/distributed-data/dbbakServer/data/#将要备份的数据库database_dispatching=centralized_dispatchingdatabase_fault=cdispatching_faultdatabase_complaint=cdispatching_complaint#如果文件夹不存在则创建if

运维之路

gitlab备份脚本

101.133.234.5580www.haoruicloud.comdockerrun-d--namenps--net=host-v/data/conf/:/confffdfgdfg/npsdockerrun-d--namenpc--net=host-v/data/conf/:/confffdfgdfg/npc-config=/data/conf/npc.confcp-a/etc/apt/sources.list.bak1/etc/apt/sources.listAPIKey已创建API访问地址:https://rancher.fenglincloud.com/v3AccessKey(用户名):token-rj8n9SecretKey(密码):4l5x7lw8w6dn9nx8xql4fkl44t2x4m5xwcfsqvmw6hddmqvqlvcj6fAccessKey和SecretKey可以作为HTTP基本身份验证的用户名和密码发送,以授权请求。您也可以将它们组合为BearerToken:BearerToken:token-rj8n9:4l5x7lw8w6dn9nx8xql4fkl44t2x4m5xwcfsqvmw6hddmqvqlvcj6fvar=`$JOB_NAME:dev-n-$BUILD_NUMBER`#!/bin/bash#gitlab机房备份路径LocalBackDir=/backup/bak#远程备份服务器gitlab备份文件存放路径RemoteBackDir=/www/wwwroot/wiki.fenglincloud.com/dev#远程备份服务器登录账户RemoteUser=root#远程备份服务器IP地址RemoteIP=106.15.238.104#当前系统日期DATE=`date+"%Y-%m-%d"`#Log存放路径LogFile=$LocalBackDir/log/$DATE.log#将数据所在文件夹bak打包tar-zcvf$(LocalBackDir)$(date+%Y%m%d).tar.gz$LocalBackDir#查找本地备份目录下时间为60分钟之内的,并且后缀为.tar.gz的备份文件BACKUPFILE_SEND_TO_REMOTE=$(find/backup/bak-typef-mmin-60-name'*.tar.gz*')#复制文件cp-r/data/$LocalBackDir#新建日志文件touch$LogFile#追加日志到日志文件echo"Gitlabautobackuptoremoteserver,startat$(date+"%Y-%m-%d%H:%M:%S")">>$LogFileecho"---------------------------------------------------------------------------">>$LogFile#输出日志,打印出每次scp的文件名echo"---------------------Thefiletoscptoremoteserveris:$BACKUPFILE_SEND_TO_REMOTE-------------------------------">>$LogFile#备份到远程服务器scp$BACKUPFILE_SEND_TO_REMOTE$RemoteUser@$RemoteIP:$RemoteBackDir#追加日志到日志文件echo"---------------------------------------------------------------------------">>$LogFilefind/backup/bak-mmin+1-name"*.tar.gz"-execrm-rf{}\;#追加日志到日志文件echo"-------删除过期备份文件------------------------------------------------------------">>$LogFiledockerpullharbor.fenglincloud.com/center/java:8dockertagregistry.cn-shanghai.aliyuncs.com/taro-mall/java:8_server-jreharbor.fenglincloud.com/operations/java:8_server-jre#!/bin/sh#复制文件cp-r/data/redis/backup/bakcp-r/data/mongo/backup/bakcp-r/data/mysql/backup/bak#将数据所在文件夹bak打包tar-zcvf/backup/bak$(date+%Y%m%d).tar.gz/backup#删除临时文件内容rm-rf/tmp/backup/bak#删除改文件夹下超过2小时的文件find./-mmin+120-name"*.tar.gz"-execrm-rf{}\;scp$BACKUPFILE_SEND_TO_REMOTE$RemoteUser@$RemoteIP:$RemoteBackDir

运维之路

linux初部署shell脚本

#!/bin/bashcp-a/etc/apt/sources.list/etc/apt/sources.list.bak2#保存备份文件sed-i"s@http://.*archive.ubuntu.com@http://mirrors.huaweicloud.com@g"/etc/apt/sources.list#替换源sed-i"s@http://.*security.ubuntu.com@http://mirrors.huaweicloud.com@g"/etc/apt/sources.list#替换源apt-getupdate#更新源aptinstalldocker.io-y#安装dockersystemctlstartdocker#启动dockersystemctlenabledocker#开机自启动docker-v#查看docker安装是否成功sudogroupadddockersudogpasswd-a${USER}dockersudoservicedockerrestartwgethttp://slhl.shyyhy.com/daemon.jsonmvdaemon.json/etc/docker/daemon.json#更换国内源#vim/etc/docker/daemon.json#{#"registry-mirrors":

Title - Artist
0:00