http://www.cnblogs.com/hackerer/p/5243639.html
http://www.ttlsa.com/web/let-infotify-rsync-fast/
http://sookk8.blog.51cto.com/455855/328076/
wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
tar zxf inotify-tools-3.14.tar.gz
uname -r
cd inotify-tools-3.14
./configure --prefix=/usr/local/inotify-tools-3.14
make
make install
ln -s /usr/local/inotify-tools-3.14/ /usr/local/inotify-tools
cd /usr/local/inotify-tools
cd bin/
[root@localhost bin]# ll 可以看到有2个监控命令:
总用量 88
-rwxr-xr-x 1 root root 44271 3月 1 19:23 inotifywait
-rwxr-xr-x 1 root root 41393 3月 1 19:23 inotifywatch
You have new mail in /var/spool/mail/root
指定监控的事件:
[root@localhost bin]# ./inotifywait -mrq --timefmt '%d%m%y%H:%m' --format '%T%w%f' -e create /backup 类似这样的格式
06031723:03/backup/101
06031723:03/backup/102
06031723:03/backup/103
06031723:03/backup/104
history
比如一个脚本:
#!/bin/sh
cmd="/usr/local/inotify/bin/inotifywait"
$cmd -mrq --format '%w%f'-e create, close_write ,delete /backup \换行
while read line
do
rsync -az --delete $line rsync_backup@x.x.x.x::bakcup --password-file=/etc/rsync.password
done
##rsyncd.conf start###工作中指定用户(需要指定用户)
uid = rsync
gid = rsync
use chroot = no
max connections = 200
timeout = 300
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
【backup】指定模块
path = /backup
read only = false
list = false
hosts allow = 172.17.0.29/32 允许的地址连接
hosts deny = 0.0.0.0/32 拒绝的地址连接
auth users = rsync_backup #虚拟用户名
secrets file = /etc/rsync.password #对应的密码
rsync_config_______________end