服务端做的
cd /usr/port/net/rsync
make config && make install clean
uid = www
gid = www
use chroot = yes
read only = yes # 只读
hosts allow=允许复制的ip
max connections = 5 # 最大连接数为5
timeout = 300
[www] # 这里是认证的模块名,在client端需要指定
path = /usr/local/www/apache22/data
list=no # 不允许列文件
ignore errors # 可以忽略一些无关的IO错误
auth users = rsyncuser # 认证的用户名,如果没有这行,则表明是匿名
secrets file = /usr/local/etc/rsyncd.secrets # 认证文件名
comment = www file
echo "rsyncuser:rsync_0" > /usr/local/etc/rsyncd.secrets
echo "/usr/local/bin/rsync --daemon" >> /etc/rc.conf
echo "rsyncd_enable=\"YES\"" >> /etc/rc.conf
chmod 600 /usr/local/etc/rsyncd.secrets #出于安全的目的,必须只有属主可读
客户端做的
cd /usr/port/net/rsync
make config && make install clean
echo "rsync_0" >> /usr/local/etc/rsyncd.bakup.passwd (在客户端写上在服务端的密码)
vi /usr/local/etc/rsyncd.sh写入
rsync -avz --delete rsync://rsyncuser@125.90.88.207/www /usr/local/www/apache22/data --password-file=/usr/local/etc/rsyncd.bakup.passwd
chmod 600 /usr/local/etc/rsyncd.bakup.passwd #出于安全必须只有属主可读
做计划任务
crontab -e
* 8 * * * /usr./local/etc/rsyncd.sh
要临时同步的时候
/usr/local/etc/rsyncd.sh