Inotify + rsync:
Requirements:
Rsync3.x
Inotify-Tools
Condition:
Two hosts to be synchronized in Real Time:
10.3.0.173 Server
10.3.0.215 distributor
Synchronized website directory:/home/rsync/
1
Install:
# Cd/usr/local/src
# Wget http://www.samba.org/ftp/rsync/s... nc-3.0.6pre1.tar.gz
# Wget http://jaist.dl.sourceforge.net/... y-tools-3.13.tar.gz
Server installation:
# Tar zxvf rsync-3.0.6pre1.tar.gz
# Cd rsync-3.0.6pre1
#./Configure -- prefix =/usr & make install
Distribution and installation:
# Tar zxvf inotify-tools-3.13.tar.gz
# Cd inotify-tools-3.13
#./Configure & make install
#Ln-SV/usr/local/lib/libinotify *
/Usr/lib/
Server configuration file:
Vim/etc/rsyncd. conf
Chmod 600
/Etc/rsyncd. conf
Distribution script:
Vim/etc/rsync. Pass
Chmod 600
/Etc/rsync. Pass
Vim/etc/inotify. Sh
1 #! /Bin/sh
2 src =/home/wwwroot/rsync/
3 DES = Log
4 IP = 10.3.0.173
5
6/usr/local/bin/inotifywait-mrq -- timefmt
'% D/% m/% Y % H: % m' -- format' % T % w % F '\
7-e modify, delete, create, attrib \
8 $ {SRC }\
9 | while read files
10
Do
11 rsync
-Vzrtopg -- delete -- Progress -- password-file =/etc/rsync. Pass $ {SRC}
Root @ $ {IP }:: {des}
12
Echo "$ {SRC} was rsynced"
13
Echo "-----------------------------------------------------"
14
Done
~
Chmod A + x/etc/inotify. Sh
/Etc/inotify. Sh &
Echo "/etc/inotify. Sh &">
/Etc/rc. Local