码迷,mamicode.com
首页 > 其他好文 > 详细

rsync+inotify 实时同步脚本学习笔记

时间:2017-08-28 20:00:31      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:rsync+inotify 实时同步脚本学习笔记

#!/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


rsync+inotify 实时同步脚本学习笔记

标签:rsync+inotify 实时同步脚本学习笔记

原文地址:http://heavenfish.blog.51cto.com/9841104/1959701

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!