下文内容主要给大家带来记录mysql 备份脚本,这里所讲到的知识,与书籍略有不同,都是创新互联专业技术人员在与用户接触过程中,总结出来的,具有一定的经验分享价值,希望给广大读者带来帮助。
创新互联公司主要从事网站设计、做网站、网页设计、企业做网站、公司建网站等业务。立足成都服务雁江,10余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18982081108mysql备份脚本,记录一下:
全备:
#!/bin/sh set -x USER=root PASSWORD=123456 time=`date +"%y-%m-%d-%H-%M"` date >> /data/mysqlbackup/logs/$time'_allbackup.log' #1 begin Full Backups echo "begin backup--------------------------------" >> /data/mysqlbackup/logs/$time'_allbackup.log' /usr/bin/innobackupex --defaults-file=/etc/my.cnf --user=$USER --password=$PASSWORD --use-memory=2GB --parallel=4 --no-timestamp /data/mysqlbackup/full-$time 2>>/data/mysqlbackup/logs/$time'_allbackup.log' cp /etc/my.cnf /data/mysqlbackup/full-$time/my.cnf.bk echo "end backup----------------------------------" >> /data/mysqlbackup/logs/$time'_allbackup.log' #2 begin compress echo "Begin compress------------------------------" >> /data/mysqlbackup/logs/$time'_allbackup.log' archivename=full-$time echo "The archive time is $time" >> /data/mysqlbackup/logs/$time'_allbackup.log' tarname=$archivename.tar.gz echo "The tar name is $tarname" >> /data/mysqlbackup/logs/$time'_allbackup.log' cd /data/mysqlbackup /bin/tar -zcvf ./$tarname ./$archivename >> /data/mysqlbackup/logs/$time'_allbackup.log' 2>&1 rm -rf /data/mysqlbackup/full/xtrabackup_checkpoints cp /data/mysqlbackup/full-$time/xtrabackup_checkpoints /data/mysqlbackup/full/xtrabackup_checkpoints#3 Delete Document
file=/data/mysqlbackup/$tarname if [[ -e $file ]] then echo "The $tarname file exists.begin to perform delete action" >> /data/mysqlbackup/logs/$time'_allbackup.log' /bin/rm -rf /data/mysqlbackup/$archivename else echo "The file is not exists." >> /data/mysqlbackup/logs/$time'_allbackup.log' fi date >> /data/mysqlbackup/logs/$time'_allbackup.log' find /data/mysqlbackup/*tar.gz -ctime +1|xargs -I '{}' mv {} /data/ftp cd /data/ftp function logftp (){ ftp -v -n xxx.xxx.xxx.xxx << EOF user username password binary hash cd ftp_mysql prompt put /data/mysqlbackup/*tar.gz ls -la bye EOF } logftp >>/data/mysqlbackup/logs/to_ftp.log cd /data/ftp find /data/ftp/*tar.gz |xargs rm -rf增量备份:
#!/bin/sh set -x USER=root PASSWORD=123456 time=`date +"%y-%m-%d-%H-%M"` date >>/data/mysqlbackup/logs/$time'_incre.log' #1 begin Incre Backups echo "begin backup--------------------------------" >> /data/mysqlbackup/logs/$time'_incre.log' /usr/bin/innobackupex --defaults-file=/etc/my.cnf --user=$USER --password=$PASSWORD --incremental --incremental-basedir=/data/mysqlbackup/full --use-memory=2GB --safe-slave-backup --parallel=4 --slave-info --no-timestamp /data/mysqlbackup/incre-$time 2>>/data/mysqlbackup/logs/$time'_incre.log' cp /etc/my.cnf /data/mysqlbackup/incre-$time/my.cnf.bk echo "end backup----------------------------------" >> /data/mysqlbackup/logs/$time'_incre.log' #2 begin compress echo "Begin compress------------------------------" >> /data/mysqlbackup/logs/$time'_incre.log' archivename=incre-$time echo "The archive time is $time" >> /data/mysqlbackup/logs/$time'_incre.log' tarname=$archivename.tar.gz echo "The tar name is $tarname" >> /data/mysqlbackup/logs/$time'_incre.log' cd /data/mysqlbackup/ /bin/tar -zcvf ./$tarname ./$archivename >> /data/mysqlbackup/logs/$time'_incre.log' 2>&1 #3 Delete Document file=/data/mysqlbackup/$tarname if [[ -e $file ]] then echo "The $tarname file exists.begin to perform delete action" >> /data/mysqlbackup/logs/$time'_incre.log' /bin/rm -rf /data/mysqlbackup/$archivename else echo "The file is not exists." >> /data/mysqlbackup/logs/$time'_incre.log' fi date >> /data/mysqlbackup/logs/$time'_incre.log' find /data/mysqlbackup/*tar.gz -ctime +1|xargs -I '{}' mv {} /data/ftp cd /data/ftp function logftp (){ ftp -v -n xxx.xxx.xxx.xxx << EOF user username password binary hash cd ftp_mysql prompt put /data/mysqlbackup/*tar.gz ls -la bye EOF } logftp >>/data/mysqlbackup/logs/to_ftp.log cd /data/ftp find /data/ftp/*tar.gz |xargs rm -rf对于以上关于记录mysql 备份脚本,如果大家还有更多需要了解的可以持续关注我们创新互联的行业推新,如需获取专业解答,可在官网联系售前售后的,希望该文章可给大家带来一定的知识更新。
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
分享题目:记录mysql备份脚本-创新互联
分享网址:https://www.cdcxhl.com/article28/dhhpcp.html
成都网站建设公司_创新互联,为您提供响应式网站、ChatGPT、外贸建站、企业网站制作、做网站、微信小程序
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联