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 {} \;
posted @ 2020-01-16 18:32  Ray_chen  阅读(202)  评论(0编辑  收藏  举报