rsync+inotify

 


192.168.1.88 有文件 /web 要到  192.168.1.189  /web

 

===================192.168.1.88==================================================

[[email protected]]#tar zxvf inotify-tools-3.14.tar.gz

[[email protected]]#cd inotify-tools-3.14

[[email protected] inotify-tools-3.14]# ./configure --prefix=/usr/local/inotify-tools

[[email protected] inotify-tools-3.14]# make && make install


vi /etc/rsyncd.secrets
root:123

 

[root@kk22 ~]# cat inotify.sh

#!/bin/bash

#


host1=192.168.1.189            ##服務器端IP

src=/web/                      ##本地數據存放目錄

dst=web                        ##服務端數據的目錄

user=root                      ##主機A允許推送拉取數據的用戶

 

/usr/local/inotify-tools/bin/inotifywait -mrq  -e modify,delete,create,attrib $src | while read line ; do

/usr/bin/rsync -vzrtopg --delete --progress --password-file=/etc/rsyncd.passwd $src $user@$host::$dst

done
[[email protected] ~]# vi inotify.sh
[[email protected] ~]# ./inotify.sh

 


========================192.168.1.189=============================================

yum install xinetd
service xinetd start
chkconfig rsync  on

 


[[email protected]]# cat /etc/rsyncd.conf
pid file = /var/run/rsyncd.pid
port = 873
uid = root
gid = root
user chroot = yes
read only = no
write only = no
hosts allow=192.168.1.0/255.255.255.0
host deny=*
mac connections = 2
log file = /var/log/rsync.log
log format = %t %a %m %f %b
timeout = 300
[web]
path = /web
list = yes
ignore error
auth user = root
secrets file = /etc/rsyncd.secrets
exclude = 222/

 

vi /etc/rsyncd.secrets
root:123

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章