rsync+inotify实时同步

来源:互联网 发布:mac 小红点 编辑:程序博客网 时间:2024/04/30 13:51
试验环境
192.168.10.102 安装rsync 配置rsync.conf
192.168.10.103 安装inotify,rsync


在102上做的操作,主推到103上


132.63.10.73


要有rsync


#vi /etc/rsyncd.conf
uid = root
gid = root
read only = no
use chroot = no
max connections = 512
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
log format = %t %a %m %f %b


[test]
path = /tongbu
list = no
ignore errors 
auth users = backup
hosts allow = 192.168.10.72
hosts deny = *
secrets file = /etc/rsyncd.pwd




#vi /etc/rsyncd.pwd
backup:123456


#chmod 600 /etc/rsyncd.conf
#chmod 600 /etc/rsyncd.pwd


#rsync --daemon
#echo "rsync --daemon" >> /etc/rc.local


132.63.10.72
安装inotify


#vi /tmp/rsync.sh
!/bin/bash
src=/tongbu/
dst=backup@192.168.10.73::test
inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib $src |while read files
do
rsync -vzrtopg --delete --progress --password-file=/home/rsyncd.pwd $src $dst
#rsync -vzrtopg --delete --progress --password-file=/home/rsyncd.pwd backup@192.168.10.73::snmp /tongbu
done


#chmod +x /tmp/rsync.sh
#vi /home/rsyncd.pwd
123456
#chmod 600 /home/rsyncd.pwd


#/tmp/rsync.sh &


#echo "/tmp/rsync.sh" >> /etc/rc.local
0 0
原创粉丝点击