Function:
Monitor a directory on the specified server and automatically sync to another server
#!/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=/dat A/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 darl Ing@${r1}::root${desthostdir} &>/dev/null && \ echo "at ${time} on ${date}, file $FILECHANGE is BAC ked 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 is backed up V IA rsync ">> $LOG rsync-avz--password-file=/etc/rsyncd/rsyncd.pass $FILECHANGE darling@${r3}::root${
Desthostdir} &>/dev/null && \ echo ' at ${time} on ${date}, file $FILECHANGE is backed up via rsync ' >> $LOG done
This article address: http://www.bianceng.cn/Servers/zs/201602/49605.htm
This article comes from "Acridine a Pooh" blog, please be sure to keep this source http://gm100861.blog.51cto.com/1930562/935176