#!/bin/bash #para host01=192.168.213.3 #inotify-slave的ip地址 src=/backup/ #本地监控的目录 dst=backup #inotify-slave的rsync服务的模块名 #user=rsync_backup #inotify-slave的rsync服务的虚拟用户,没有设置虚拟用户可以省略 #rsync_passfile=/etc/rsync.password #本地调用rsync服务的密码文件,没有设置虚拟用户密码的可以省略 #inotify_home=/usr/local/inotify-3.14 #inotify的安装目录,如果是yum安装则省略 #judge if [ ! -e "$src" ] || [ ! -e "/usr/bin/inotifywait" ] || [ ! -e "/usr/bin/rsync" ]; #|| [ ! -e "${rsync_passfile}" ] \ #如果没有设置虚拟账户密码,此判断省略 #|| [ ! -e "${inotify_home}/bin/inotifywait" ] \ #如果是yum安装则替换为 || [ ! -e "usr/bin/inotifywait" ] #如果是yum安装则替换为 || [ ! -e "usr/bin/inotifywait" ] 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,create,attrib $src \ /usr/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f' -e close_write,delete,create,attrib $src \ | while read file do # rsync -avzP --delete --timeout=100 --password-file=${rsync_passfile} $src $user@$host01::$dst >/dev/null 2>&1
本文由 Mr Gu 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: Aug 26, 2016 at 09:24 pm