Get the App
SLTechnology News&Howtos  ›  Database  › 

Record mysql backup script

Shulou Source: shulou.com Published: 2022-06-01 20:46:54 11月19日 Update

The following content mainly brings you to record mysql backup script, the knowledge here is slightly different from books, are summed up by professional and technical personnel in the process of contact with users, have a certain experience sharing value, hope to bring help to the majority of readers.

Mysql backup script, record:

Complete:

#! / bin/sh set-x USER=root PASSWORD=123456time= `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.bkecho "end backup- -"> > / data/mysqlbackup/logs/$time'_allbackup.log' # 2 begin compress echo" Begin compress-- "> / data/mysqlbackup/logs/$time'_allbackup.log' archivename=full-$timeecho" The archive time is $time "> > / data/mysqlbackup/logs/$time'_allbackup.log' tarname=$archivename.tar.gz echo "The tarname is $tarname" > > / data/mysqlbackup/logs/$time'_allbackup.log'cd / data/mysqlbackup/bin/tar-zcvf. / $tarname. / $archivename > > / data/mysqlbackup/logs/$time'_allbackup.log' 2 > & 1rm-rf / data/mysqlbackup/full/xtrabackup_checkpoints cp / data/mysqlbackup/full-$time/xtrabackup_checkpoints / data/mysqlbackup/full/xtrabackup_checkpoints

# 3 Delete Documentfile=/data/mysqlbackup/$tarnameif [[- 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' fidate > > / data/mysqlbackup/logs/$time'_allbackup.log'find / data/ Mysqlbackup/*tar.gz-ctime + 1 | xargs-I'{}'mv {} / data/ftpcd / data/ftpfunction logftp () {ftp-v-n xxx.xxx.xxx.xxx > / data/mysqlbackup/logs/to_ftp.logcd / data/ftpfind / data/ftp/*tar.gz | xargs rm-rf

Incremental backup:

#! / bin/shset-xUSER=rootPASSWORD=123456time= `date + "% y-%m-%d-%H-%M" `date > > / data/mysqlbackup/logs/$time'_incre.log'#1 begin Incre Backupsecho "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.bkecho "end backup-- -"> / data/mysqlbackup/logs/$time'_incre.log'#2 begin compressecho" Begin compress-- "> > / data/mysqlbackup/logs/$time'_incre.log' archivename=incre-$timeecho" The archive time is $time "> > / data/mysqlbackup/logs/$time'_incre.log' tarname=$archivename.tar.gzecho" The tarname is $tarname "> > / data/mysqlbackup / logs/$time'_incre.log'cd / data/mysqlbackup//bin/tar-zcvf. / $tarname. / $archivename > > / data/mysqlbackup/logs/$time'_incre.log' 2 > & 1x3 Delete Documentfile=/data/mysqlbackup/$tarnameif [[- 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' fidate > > / data/mysqlbackup/logs/$time'_incre.log'find / data/mysqlbackup/*tar.gz-ctime + 1 | xargs-I'{}'mv {} / data/ftpcd / data/ftpfunction logftp () {ftp-v-n xxx.xxx.xxx.xxx > / data/mysqlbackup/logs/to_ftp.logcd / data/ftpfind / data/ftp/*tar.gz | xargs rm-rf

For the above recording mysql backup script, if you need to know more, you can continue to follow our industry promotion, if you need professional answers, you can contact the pre-sales and after-sales on the official website. I hope this article can bring you some knowledge updates.

Tags: Backups scripts specialties knowledge differences below books people value content available in incremental technical more users experience industry readers processes complete Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS MySQL Linux Apple Shulou Technology