-
-
Save wxianfeng/2379200 to your computer and use it in GitHub Desktop.
rsync 同步备份
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
# m h dom mon dow command | |
0 4 * * * /bin/sh /data/shell/rsync.sh >> /data/shell/output.txt 2>&1 # 每天早晨4点执行 |
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
# 本地同步 | |
>rsync -a --delete /home /backups |
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/sh | |
# http://www.howtocn.org/rsync:use_rsync | |
# -a 归档模式,表示以递归方式传输文件,并保持所有文件属性 | |
# -v 输出详细log | |
# -z 在传输文件时就行压宿处理 | |
# --delete 删除那些接收端还有而发送端已经不存在的文件 | |
echo "rsync attachments" | |
rsync -avz --delete /data/projects/project_manager/public/attachments root@wxianfeng.com:/data/back/huaianxinao_com/ | |
echo "rsync attachments ended" | |
echo "rsync mysql databases;" | |
cd /data/backup | |
TODAY=`date +'%Y_%m_%d'` | |
/usr/bin/mysqldump -uroot -pwxfykl project_manager_production > project_manager_production_"$TODAY".txt | |
rsync -avz --delete /data/backup/project_manager_production_"$TODAY".txt root@wxianfeng.com:/data/back/huaianxinao_com/ | |
echo "rsync mysql databases ended;" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment