`

rsync+inotify

 
阅读更多

[server端] rsync安装 wget http://rsync.samba.org/ftp/rsync/rsync-3.0.9.tar.gz tar -xvzf rsync-3.0.9.tar.gz; cd rsync-3.0.9; ./configure; make; make install vi /usr/local/rsync/etc/rsync.passwd 123456 chmod 600 /usr/local/rsync/etc/rsync.passwd inotify安装 wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz tar -xzvf inotify-tools-3.14.tar. ./configure --prefix=/urs/local/inotify make make install 创建rsync复制脚本文件 rsync.sh #! /bin/bash host0=192.168.10.6 host1=192.168.10.8 src=/data/serverdata dst0=client0 dst1=client1 user0=client0 user1=client1 /usr/local/inotify/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib $src | while read files do /usr/local/rsync/bin/rsync -vzrtopg --delete --progress --password-file=/usr/local/rsync/etc/server.pass $src $user0@host0::$dst0 /usr/local/rsync/bin/rsync -vzrtopg --delete --progress --password-file=/usr/local/rsync/etc/server.pass $src $user1@host1::$dst1 echo "$(files) was rsynced" >> /tmp/rsync.log 2>&1 chmod 764 rsync.sh 运行rsync.sh (客户端配置好后) sh rsync.sh & 开机自启动 echo “/tmp/rsync.sh &” >> /etc/rc.local [client端] wget http://rsync.samba.org/ftp/rsync/rsync-3.0.9.tar.gz tar -xvzf rsync-3.0.9.tar.gz; cd rsync-3.0.9; ./configure; make; make install rsync服务器端配置 vi /etc/rsyncd.conf(需要手动生成) uid = root gid = root use chroot = no max connections = 4 strict modes = yes pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock log file = /var/log/rsyncd.log [client0] path = /data/client0data comment = client1 file ignore errors read only = no write only = no list = false hosts allow = 192.168.10.6 hosts deny = * uid = root gid = root auth users = davy secrets file = /usr/local/rsync/etc/client0.pass vi /usr/local/rsync/etc/client0.pass davy:123456 chown root:root /usr/local/rsync/etc/client0.pass chmod 600 /usr/local/rsync/etc/client0.pass 启动rsync服务 /usr/local/bin/rsync --daemon --config=/etc/rsyncd.conf 加入开机启动 echo “/usr/local/bin/rsync --daemon --config=/etc/rsyncd.conf” >>/etc/rc.local

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics