mysqldump不锁表备份single-transaction

时间:2021-06-24 18:11:54   收藏:0   阅读:0

 

[root@es02-010007081131 dumpbackup]# more /home/script/backup/mysql_dumpbackup.sh
#!/bin/bash
. /etc/profile
. ~/.bash_profile
backup_date=`date "+%Y%m%d"`
delete_date=`date +%Y%m%d -d "7 days ago"`

##生产数据库名清单
/home/middle/mysql57/bin/mysql -h localhost -uubackup -ptest -N -e "show databases"> /tmp/dblist.txt


##循环每个数据库备份
cat /tmp/dblist.txt|grep -v mysql|grep -v performance_schema|grep -v information_schema |grep -v sys|while read line
do

db_name=$line

mysqldump_file=/home/mysqlbak/dumpbackup/${db_name}_${backup_date}.xz
/home/middle/mysql57/bin/mysqldump -h localhost -uubackup -ptest ${db_name} --default-character-set=utf8 --set-gtid-purged=OFF --skip-tz-utc --skip-disable-keys --skip-add-locks --single-transaction|xz >${mysqldump_file}

delete_file=/home/mysqlbak/dumpbackup/${db_name}_${delete_date}.xz

##删除本地文件
if [ -f "${delete_file}" ];then
  rm ${delete_file}
fi


done

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!