Skip to content

Instantly share code, notes, and snippets.

@wxianfeng
Created April 13, 2012 18:58
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 wxianfeng/2379200 to your computer and use it in GitHub Desktop.
Save wxianfeng/2379200 to your computer and use it in GitHub Desktop.
rsync 同步备份
# m h dom mon dow command
0 4 * * * /bin/sh /data/shell/rsync.sh >> /data/shell/output.txt 2>&1 # 每天早晨4点执行
# 本地同步
>rsync -a --delete /home /backups
#!/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