#!/bin/sh
#para
host01=192.168.100.61
src=/backup
dst=oldboy
user=rsync_backup
rsync_passfile=/etc/rsync.password
inotify_home=/usr/local/inotify-tools-3.14/
#judge
if [ ! -e "$src" ] \
|| [ ! -e "${rsync_passfile}" ] \
|| [ ! -e"${inotify_home}/bin/inotifywait" ] \
|| [ ! -e "/usr/bin/rsync" ] ;
then
echo "Check File and Folder"
exit 9
fi
${inotify_home}/bin/inotifywait -mrq--timefmt '%d/%m/%y %H:%M' --format '%T %w%f' -e close_write,delete,cre
ate,attrib $src \
|while read file
do
cd $src && rsync -aruz -R --delete ./ --timeout=100$user@$host01::$dst --password-file=${rsync_pass
file} >/dev/null 2>&1
done
exit 0