#!/bin/bash
# Filename: inotify.sh

srcDir=/usr/local/src
modName=data
dstServers=127.0.0.1

authUser=www
passFile=/etc/rsyncd.auth     # password file must not be other-accessible.

RSYNC_OPTS="-vzrtopg --progress --delete"
INOTI_OPTS="-mrq --timefmt '%d-%m-%y %H:%M' --format '%T %w %fi %e' --event modify,delete,create,attrib "

#Wait for change
inotifywait ${INOTI_OPTS} ${srcDir}| while read files
do
	rsync ${RSYNC_OPTS} --password-file=${passFile} ${srcDir} ${authUser}@${dstServers}::${modName}
done
