rsync+inotify

wget https://cloud.github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz

wget https://rsync.samba.org/ftp/rsync/rsync-3.1.1.tar.gz



#!/bin/sh

#date:2015-5-27

#function:rysnc 109.26  to  96.48


log=/tmp/rsync.log

src="/data/"

host="10.139.96.48"

module="/data/backup/data"

 

/usr/local/bin/inotifywait -mr --timefmt '%d/%m/%y %H:%M' --format '%T %w %f' -e close_write,modify,delete,create,attrib $src |  while read DATE TIME DIR FILE; do

 

       FILECHANGE=${DIR}${FILE}

 

       #/usr/bin/rsync -avH --delete  --progress --password-file=/etc/data.pass $src  --exclude-from="/usr/local/inotify/logs/rules.txt" rsyncuser@$host::$module &

       #/usr/bin/rsync -avH --delete  --progress --password-file=/etc/data.pass $src   www@$host::$module &

       /usr/bin/rsync -aH  --delete  -e 'ssh -p 9902'   --progress  $src   zhanglili@$host:$module &

       echo "At ${TIME} on ${DATE}, file $FILECHANGE was backed up via rsync" >> $log

done


你可能感兴趣的:(function,create,modify)