#!/bin/bash
src=/xxx/xxx #本地监控目录
des_ip="192.168.1.2 192.168.1.3" #目标服务器
/usr/local/bin/inotifywait -mrq --timefmt ‘%d/%m/%y %H:%M‘ --format ‘%T %w%f‘ \
--exclude "\.swp$" \
--exclude=/backup/ \
-e close_write,modify,delete,create,attrib,move \
${src} \
| while read file
do
rsync -vagtopg --delete --progress $src 192.168.1.2::xxx/ >> /var/log/rsync.log #同步
rsync -vagtopg --delete --progress $src 192.168.1.3::xxx/ >> /var/log/rsync.log
done
原文地址:http://314258.blog.51cto.com/304258/1632992