码迷,mamicode.com
首页 > 数据库 > 详细

mysqldump不锁表备份single-transaction

时间:2021-06-24 18:11:54      阅读:0      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!