#!/bin/bash
# This rsync script based on inotify.

export PATH=/bin:/usr/bin:/usr/local/bin
src=/www/
dst=data
client=172.16.10.104

user=backup
#password file must not be other-accessible.
Passfiles=/etc/rsyncd.auth

#Wait for change
inotifywait -mrq --timefmt '%d-%m-%y %H:%M' --format '%T %w %fi %e' --event modify,delete,create,attrib $src|while read files 
	do
	rsync -vzrtopg --progress --delete --password-file=$Passfiles $src $user@$client::$dst
	echo "${files} was rsynced" >> /var/log/inotify_web 2>&1
	done
	


