mysql备份

#!/bin/bash

mysqldump=/usr/local/mysql/bin/mysqldump
backdir=/home/mysql_backup
backdate=`date +%Y%m%d_%H%M%S`
backname=368mysql_${backdate}
remotedir=/home/368_mysql/

${mysqldump} -uroot  --single-transaction --master-data=2 --set-gtid-purged=OFF  --all-databases --routines --events --flush-logs | gzip >$backdir/$backname.gz

scp -P22 $backdir/$backname.gz  ip:${remotedir}

find $backdir  -mtime +7  -exec rm -rf {} \;

你可能感兴趣的:(mysql备份)