Server IP:172.18.5.251 Hostname: freebsd-1
Client IP:172.18.5.247 Hostname: freebsd-2
apache_1.3.29
rsync-2.5.7
Step 1: 安装
Step 3: 配置rsyncd.conf
[www]
comment = web server backup
path = /usr/local/www/data-dist
auth users = tonny
uid = nobody
gid = nogroup
secrets file = /usr/local/etc/rsyncd.secrets
read only = no
tonny:123456 // 认证所需的用户名/密码
freebsd-1#chmod 600 rsyncd.secrets
rsyncd_enable="YES"
command_args="-4 --daemon" <<<--- 启用ipv4 协议
freebsd-1#/usr/local/etc/rc.d/rsyncd.sh start
二,Rsync Client
Step 1: 安装
123456 //Rsync Server上的认证密码,不用输入用户名
freebsd-2#chmod 600 rsyncd.secrets
Step 5: Auto Rsync Shell:
freebsd-2#chmod a-x rsyncd.sh
freebsd-2#vi rsync.sh //加入以下内容
#!/bin/sh
/usr/local/bin/rsync -avzP --delete
--password-file=/usr/local/etc/rsyncd.secrets tonny@172.18.5.251::www
/backup/www/
freebsd-2#chmod a+x rsync.sh
freebsd-2#crontab -e //加入以下内容(每天下午5点半自动备份同步)
30 17 * * * /usr/local/etc/rc.d/rsync.sh
三,高级应用(Rsync With SSH)
Rsync Server
Rsync Client
freebsd-2#scp ~/.ssh/id_dsa.pub 172.18.5.251:/root/.ssh/authorized_keys
freebsd-2#ssh-agent csh 或 (ssh-agent bash) --->>> #echo $SHELL
查看当前SHELL
freebsd-2#ssh-add id_dsa --->>> 输入 passphase
freebsd-2#/usr/local/bin/rsync -avzP --delete -e ssh
172.18.5.251:/usr/local/www/data-dist/ /backup/www/
PS: 参数说明
-a, --archive archive mode, equivalent to -rlptgoD
//档案模式
-v, --verbose
//详细模式
-z, --compress compress file data
//压缩文件
-P equivalent to --partial --progress
//显示进度
--delete
This tells rsync to delete any files on the receiving side
that
aren't on the sending side.
//保持远程机器的文件同步性
-e ssh use SSH connection
//使用SSH连接,保证数据安全
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/openssh.html
freebsd handbook手册