码迷,mamicode.com
首页 > 其他好文 > 详细

rsync+inotify

时间:2014-09-22 20:46:03      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:rsync inotify

 


192.168.1.88 有文件 /web 要到  192.168.1.189  /web

 

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

[root@192.168.1.88]#tar zxvf inotify-tools-3.14.tar.gz

[root@192.168.1.88]#cd inotify-tools-3.14

[root@192.168.1.88 inotify-tools-3.14]# ./configure --prefix=/usr/local/inotify-tools

[root@192.168.1.88 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
[root@192.168.1.88 ~]# vi inotify.sh
[root@192.168.1.88 ~]# ./inotify.sh

 


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

yum install xinetd
service xinetd start
chkconfig rsync  on

 


[root@192.168.1.189]# 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

rsync+inotify

标签:rsync inotify

原文地址:http://setup.blog.51cto.com/36721/1556976

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!