代码改变世界

rsync+inotifywait

2018-11-21 21:26  倒霉孩子110  阅读(133)  评论(0编辑  收藏  举报

#!/bin/bash

Path=/data

/usr/bin/inotifywait -mrq --format '%w%f' -e create,close_write,delete /data | while read line
do
        if [ -f $line ];then
                rsync -azP $line --delete rsync_nfs@192.168.200.129::nfs --password-file=/etc/rsync.password
        else
                cd $Path
                rsync -azP ./ --delete rsync_nfs@192.168.200.129::nfs --password-file=/etc/rsync.password
fi
done