Get the App
SLTechnology News&Howtos  ›  Database  › 

How to backup MySQL mysqldump slave library

Shulou Source: shulou.com Published: 2022-05-31 14:06:30 11月14日 Update

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!

Tags: Backup content method more problem helpless for this reason skills articles experience industry information information channels channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi MySQL Huawei Microsoft OPPO Reno