记录下自己服务器的配置文件rsync.conf
# Minimal configuration file for rsync daemon# See rsync(1) and rsyncd.conf(5) man pages for help# This line is required by the /etc/init.d/rsyncd script# GLOBAL OPTIONSuid = rootgid = rootuse chroot = noread only = yes#limit access to private LANshosts allow=114.215.239.111hosts deny=*max connections = 5pid file = /var/run/rsyncd.pidsecrets file = /etc/rsyn#lock file = /var/run/rsync.lock motd file = /etc/rsyncd/rsyncd.motd#This will give you a separate log filelog file = /var/log/rsync.log#This will log every file transferred - up to 85,000+ per user, per synctransfer logging = yeslog format = %t %a %m %f %bsyslog facility = local3timeout = 300# MODULE OPTIONS[bill]path = /home/bill/list=yesignore errorsauth users = billcomment = David homeexclude = important/
使用场景
(1):rsync -avzP bill@115.28.70.111::billModel /tmp/bill用bill 用户登录到服务器上,把billModel模块数据,同步到本地目录/tmp/bill上。(注意bill目录权限)(2):rsync -avzP --delete bill@115.28.70.111::bill /home/cent引入一个 –delete 选项,表示客户端上的数据要与服务器端完全一致,服务器删除了,客户端也要删除(3):rsync -avzP --delete --password-file=/tmp/rsync.password bill@115.28.70.111::bill /home/cent -–password-file=rsync.password ,这时当我们以bill用户登录rsync服务器同步数据时, 密码将读取 /tmp/rsync.password 这个文件。这个文件内容只是bill用户的密码。rsync.password文件要有600权限 有点是在做定时脚本的时候就不需要人工输入密码了