apt-get install rsync
cp /usr/share/doc/rsync/examples/rsyncd.conf /etc/
vi /etc/rsyncd.conf
编辑文件,按需要修改即可
auth users = appbackup # 认证的用户名,如果没有这行,则表明是匿名
secrets file = /etc/rsyncd.secrets # 认证密码文件
exclude = admin wwwroot wwwlogs #要排除的目录
vi /etc/rsyncd.secrets
格式如:username:password
chmod 600 /etc/rsyncd.conf
chmod 600 /etc/rsyncd.secrets
rsync --daemon --config=/etc/rsyncd.conf
/etc/init.d/rsync restart
记得防火墙打开873端口
客户端:
rsync -avz --progress --password-file=/etc/rsyncd.pass user@host.cn::ftp /home/hk_back/ --delete
/etc/rsyncd.pass
只需要包含密码,不用用户名
--delete参数选择是否删除服务端已经删除的文件