Inotify+rsync远程实时同步

安装inotify

yum -y install inotify-tools

写同步脚本

Path=/data
IP=172.16.100.20
/usr/bin/inotfywait -mrq --format '%w%f' -e close_write,delete $Path \
| while read i
  do 
    if [ -f $i ];then
      rsync -az $i --delete vir_rsync@Ip::bak_mod --password-file=/etc/rsync.password
    else
      cd $Path && \
      rysnc -az ./ --delete vir_rsync@Ip::bak_mod --password-file=/etc/rsync.password
    fi
done

猜你喜欢

转载自blog.csdn.net/testder/article/details/81218652