简单3步实现rsync自动增量备份

最近又被垃圾服务商折腾了,ftp备份居然不完整,最后决定用rsync做backup,避免一切意外情况- –

呃。。其实有点标题党,不过确实只有3大步骤- –

1.在需要备份的服务器上生成ssh用密钥对:ssh-keygen -t dsa -b 1024 -f /user/keys,密码留空,然后cp /user/keys.pub /user/.ssh/authorized_keys,如果已经有密钥对了跳过此步

2.把上面生成的私钥keys丢到备份服务器上,然后尝试首次同步,为了加速同步,可以先把所有文件搬到备份机,然后增量就很快了:

rsync -avz -e “ssh -i /user/keys” root@remote_server_ip:/remote_path /local_path

3.写入crontab实现自动备份

crontab -e,把这一段丢进去:@daily rsync -avz -e “ssh -i /user/keys” root@remote_server_ip:/remote_path /local_path

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.