#!/bin/bash
# author: honway.liu
# date: 2012-07-04
R1=61.147.88.114
R2=61.147.88.115
R3=222.186.32.15
DESTHOSTDIR=/data/mp3
SRCDIR=/data/music/mp3/song11
LOG=/var/tmp/mp3sync.log
inotifywait -mr --timefmt '%d/%m/%y %H:%M' --format '%T %w %f' -e close_write,modify,delete,create,attrib $SRCDIR | while read DATE TIME DIR FILE; do
FILECHANGE=${DIR}${FILE}
rsync -avz --password-file=/etc/rsyncd/rsyncd.pass $FILECHANGE darling@${R1}::root${DESTHOSTDIR} &>/dev/null &&
echo "At ${TIME} on ${DATE}, file $FILECHANGE was backed up via rsync" >> $LOG
rsync -avz --password-file=/etc/rsyncd/rsyncd.pass $FILECHANGE darling@${R2}::root${DESTHOSTDIR} &>/dev/null &&
echo "At ${TIME} on ${DATE}, file $FILECHANGE was backed up via rsync" >> $LOG
rsync -avz --password-file=/etc/rsyncd/rsyncd.pass $FILECHANGE darling@${R3}::root${DESTHOSTDIR} &>/dev/null &&
echo "At ${TIME} on ${DATE}, file $FILECHANGE was backed up via rsync" >> $LOG
done