Skip to content

Instantly share code, notes, and snippets.

@jae-jae
Last active December 12, 2016 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jae-jae/befabb3efb2a41393e878aab337f40ae to your computer and use it in GitHub Desktop.
Save jae-jae/befabb3efb2a41393e878aab337f40ae to your computer and use it in GitHub Desktop.
mysql备份shell脚本
50 0 * * * rsync -avzP root@xxx.com:/home/mysql_data_backup /home/my_site_backup/
#!/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