rsync配置说明

rsync配置说明
我的Linux发行版是SUSE11,不同的版本可能有不同

一、服务器端(默认为873端口,也可以在启动rsync时指定)
1,配置/etc/rsyncd.conf (可参考该配置文件中的example)
gid = users
read only = true
use chroot = true
transfer logging = true
log format = %h %o %f %l %b
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
hosts allow = 172.22.13.12,172.22.13.13 #trusted.hosts 这里一定要写信任的客户端,不能有空格
slp refresh = 300

[productIndex] #等同于别名
path = /prod/index #服务端文件的路径
auth users = rsyncuser #客户端登陆过来的用户名(注:客户端的密码文件中只有一个密码,不能有空格和注释等字符.不需要创建linux用户)
secrets file = /etc/rsyncd.secrets #密码文件,格式user:passwd (客户端--password-file的文件名与这个一致),自定义的文件没有成功

2,配置/etc/rsyncd.secrets 用户名:密码

3,启动rsync服务
rsync --daemon --config=/etc/rsyncd.conf  #--port 可指定端口(如果不是默认873端口,客户端也要加上参数--port)


二、客户端
rsync -vzrtopgu --progress --delete --password-file=/etc/rsyncd.secrets [email protected]::productIndex /prod/index/

#################-要注意同步的文件夹是否正确。参数-delete, 会删除客户端同步文件夹下的文件,可以不要该参数

三、创建独立的用户时需注意(如用户 us4rsync)
1,auth users = us4rsync
2,rsync -vzrtopgu --progress --delete --password-file=/etc/rsyncd.secrets [email protected]::productIndex /prod/index/
3,别忘记修改密码文件中的用户名
4,可能还要注意权限chmod 600 /etc/rsyncd.secrets


四、筛选同步文件
1,把需要同步或不需要同步的文件名写到一个文件中,如:/usr/filelist ,一个文件名一行(可使用ls 〉file命令 )
--include-from :只同步列表中的文件。 -include-from=/usr/filelist 
--exclude-from :不同步列表中的文件。-exclude-from=/usr/filelist
2,文件名配对
--include 和--exclude
例:-include = '/*.html'   只同步目录下的html文件 (/ 不能少)


猜你喜欢

转载自pwind.iteye.com/blog/857462