因为需要同步备份多个目录。本想搜下看能否看到相关的笔记,发现都是rsync配合别的工具协同实现的,所以我凭感觉测试下,在配置文件中增加多个区块,测试结果发现是正确的。算是瞎猫碰上死耗子了吧。
关于rsync的安装和配置说明,可以参考前填写的这个笔记:http://mengkang.net/148.html
同步多个目录的设置,修改配置文件
uid = root gid = root use chroot = no max connections = 4 pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock log file = /var/log/rsyncd.log [logs] path = /mnt/hgfs/code/logs [test] path = /mnt/hgfs/code/test ignore errors read only = true list = false #多个ip用空格隔开 hosts allow = 192.168.56.136 192.168.56.138 auth users = root secrets file = /etc/backserver.pas
增加了10,11行。修改后重启rsync服务。更多书写规范参考:http://www.howtocn.org/rsync:use_rsync_server
cat /var/run/rsyncd.pid | xargs kill -9 /usr/bin/rsync --daemon
重启的时候可能会提示failed to create pid file /var/run/rsyncd.pid: File exists
,删掉即可。
然后在备份服务器上执行
rsync -vzrtopg --progress --delete --password-file=/etc/rsyncd.secretes root@192.168.56.135::test /tmp/haha
执行成功,OK。