1 2 3 4 5 6 7 8 9 10 11 12 13 | # vi /etc/xinetd.d/rsync # default: off # allows crc checksumming etc. service rsync { disable = no socket_type = stream wait = no user = root server = /usr/bin/rsync server_args = --daemon log_on_failure += USERID } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # vi /etc/rsyncd.conf uid = root gid = root use chroot = yes max connections = 4 strict modes = yes syslog facility = local5 port = 873 [backup] path = /home/rsync/test/ ##要同步的文件夹 comment = This is a test ignore errors read only = no ##写权限 list = yes auth users = rsync secrets file = /etc/rsync .pas ##验证文件,对方机子也要存在这个文件 hosts allow = 192.168.1.190 ##客户端IP |
1 2 | # vi /etc/rsync.pas sync : test |
1 2 3 4 5 6 7 8 | # vi inotify_rsync.sh #!/bin/bash SRC= /home/rsync/test/ DST= rsync @192.168.1.217::backup /usr/bin/inotifywait -mrq -e modify,<del datetime= "2011-11-07T01:44:44+00:00" >delete< /del >,create,attrib ${SRC} | while read D E F do /usr/bin/rsync -ahqzt --progress <del datetime= "2011-11-07T01:44:44+00:00" >--delete< /del > --password- file = /etc/rsync .pas $SRC $DST done |
1 | # cat "/root/inotify_rsync.sh &" >> /etc/rc.local |
1 2 3 4 5 | #service portmap start #service nfs start #vi /etc/exports /home/rsync/test *(rw, sync ,no_root_squash) ##rw:可读写的权限;sync:资料同步写入存储器中; no_root_squash: 登入到NFS主机的用户如果是ROOT用户,他就用有ROOT的权限 # exportfs -rv ##重新将设定加载 |
1 | mount -t nfs 192.168.1.190: /home/rsync/test /home/rsync/test |
本文出自 “kras-linux” 博客,请务必保留此出处http://klinux.blog.51cto.com/2972664/708294