标签:read ash bin rac isa gre gtid more add
[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
mysqldump不锁表备份single-transaction
标签:read ash bin rac isa gre gtid more add
原文地址:https://www.cnblogs.com/hxlasky/p/14926133.html