inotify实时同步脚本

in 高性能 with 0 comment

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

Responses