-
-
Save jae-jae/befabb3efb2a41393e878aab337f40ae to your computer and use it in GitHub Desktop.
mysql备份shell脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 0 * * * rsync -avzP root@xxx.com:/home/mysql_data_backup /home/my_site_backup/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 配置备份路径 | |
basePath='/home/mysql_data_backup' | |
# 配置数据库 | |
dataBase='test' | |
#path=$basePath/$(date +"%Y")/$(date +"%m") | |
path=$basePath | |
mkdir -p $path | |
#Now=$(date +"%Y-%m-%d_%H%M%S") | |
Now=$(date +"%w") | |
File=$path/$dataBase-$Now.sql | |
echo "Start backup...." | |
# 配置数据库 | |
mysqldump --opt -uroot -p123456 -Q $dataBase > $File | |
echo "Your Database Backup Successfully Completed" | |
#### cron | |
# 10 0 * * * /bin/bash /home/shell/mysql-backup.sh | |
### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment