两台freebsd服务器
freebsd (ip:172.16.21.109)
freebsdclient (ip:172.16.21.68)
目标:服务器上freebsdclient( ip:172.16.21.68) /var/www/下的所有文件自动rsync到freebsd (ip:172.16.21.109)
freebsd服务器操作步骤
1.建用户并设置权限
sudo pw useradd test #创建用户test
sudo passwd test #为用户test设置密码
sudo mkdir -p /backup/www
sudo chown test :test /backup/www
2. 安装rsync,两种安装方法
sudo pkg_add -r -v rsync 或者cd /usr/ports/net/rsync && make install clean
3.配置rsyncd.conf
sudo vi /usr/local/etc/rsyncd.conf //添加如下内容:
[www]
comment=web server backup
path = /backup/www
auth users = test
uid = nobody
gid = nobody
secrets file= /usr/local/etc/rsyncd.pass
read only = on
4.配置rsyncd.pass
sudo vi /usr/local/etc/rsyncd.pass //添加以下内容
ruochen:123456 //人整天所需要的用户名和密码
chmod 600 /usr/local/etc/rsyncd.pass
5.配置rc.conf
sudo vi /etc/rc.conf //添加以下内容
rsyncd_enable="YES"
6.启动 Rsync daemon模式
/usr/local/etc/rc.d/rsyncd.pass //添加以下内容
command_args="-4 --daemon" //使用ipv4 协议
usr/local/etc/rc.d/rsyncd start
7.启动rsync
sudo /usr/local/etc/rc.d/rsync start
8.检查Rsync daemon启动状态
sockstat | grep rsync
root rsync 929 3 dgram -> /var/run/logpriv
root rsync 929 4 tcp4 *:873 *:*
freebsdclient 操作步骤
1.安装
cd /usr/ports/net/rsync
sudo make install clean
2.vi /usr/local/etc/rsyncd.pass
只有密码内容,即123456