MySQL全库备份脚本
程序员文章站
2022-04-15 21:56:18
[TOC] MySQL全库备份脚本 ......
目录
mysql全库备份脚本
vim full_database_backup.sh #!/bin/sh path="/application/mysql/bin:$path" backup1=/backup1 backup2=/backup2 time=$(date +"%f:%h:%m:%s") user=root pass=12345 mysql="mysql -u$user -p$pass" mydump="mysqldump -u$user -p$pass -a -b -r --master-data=2 --single-transaction" if [ ! -d $backup1 -o ! -d $backup2 ];then mkdir $backup1 mkdir $backup2 $mydump |gzip >/$backup1/full_${time}.tar.gz cp $backup1/full_${time}.tar.gz $backup2 echo "您好,您的mysql数据已全库备份到${backup2}/full_${time}.tar.gz" else $mydump |gzip >/$backup1/full_${time}.tar.gz cp $backup1/full_${time}.tar.gz $backup2 echo "您好,您的mysql数据已全库备份到${backup2}/full_${time}.tar.gz" fi #生产环境:cp换成rsync再扔到crontab上定时运行
上一篇: sql server如何用不同语种语言显示报错的错误消息
下一篇: 前缀和