How to backup MySQL mysqldump slave library
How to backup MySQL mysqldump from the database, I believe that many inexperienced people do not know what to do. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
#! / bin/bash
MYSQL_PATH=/data/bin
Export PATH=$PATH:$MYSQLPATH
DATABASE=***
PASSWORD=***
BACKUP_PATH=/server/backup/$ (date +% F)
BACKUP_FILE=$BACKUP_PATH/$DATABASE_$ (date +% F) .sql.gz
BACKUP_LOG=/server/error_backup_log.txt
CNF=/etc/my.cnf
OLD_PATH=/server/backup/$ (date +% F-- date='28 days ago')
Echo "$(date" +% F% T ") backup is started." > > $BACKUP_LOG
If [- d $OLD_PATH]
Then
Rm-fr $OLD_PATH & > > $BACKUP_LOG
Echo "delete the old dir $(date +% F-- date='28 days ago')" > > $BACKUP_LOG
Fi
If [!-d $BACKUP_PATH]
Then
Mkdir-p $BACKUP_PATH
Fi
Mysqldump-master-data=2-single-transaction-uroot-p$PASSWORD-F $DATABASE | gzip > $BACKUP_FILE
Cp $CNF $BACKUP_PATH
Echo "$(date" +% F% T ") backup is completed." > > $BACKUP_LOG
After reading the above, have you mastered how to back up the MySQL mysqldump slave database? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!