rsync 部署
CentOS 6
Server
secrets(服务器用户名密码)
root:123456
chmod 600 secrets
rsync.conf
uid = root
gid = root
use chroot = yes
pid file = /var/run/rsyncd.pid
log file = /var/log/rsyncd.log
[zydtest]
path = /home/zyd/file
comment = Rsync share test
auth users = root
secrets file = /usr/local/etc/rsync/secrets
read only = false
运行
rsync --daemon --config=/usr/local/etc/rsync/rsync.conf
netstat -antp | grep 873
防火墙
/etc/sysconfig/iptables(加在 REJECT 之前)
-A INPUT -p tcp -m state --state NEW -m tcp --dport 873 -j ACCEPT
开机重启
/etc/rc.local
/usr/bin/rsync --daemon --config=/usr/local/etc/rsync/rsync.conf
Client
password(服务器密码)
echo "123456" > /usr/local/etc/rsync/password
chmod 600 /usr/local/etc/rsync/password
在同步服务文件之前,可以先浏览一下服务中带共享的文件,此处可以先查看一下共享的文件
rsync --password-file=/usr/local/etc/rsync/password root@192.168.16.161::zydtest
手动同步共享目录
rsync -r --ignore-existing --password-file=/usr/local/etc/rsync/password root@192.168.16.161::zydtest /home/zyd/file
使用cron例行性任务定时从服务器同步文件