1. 程式人生 > >inotify+ rsync window同步linux伺服器資料夾

inotify+ rsync window同步linux伺服器資料夾

這裡寫圖片描述

inotify

功能ok

window 安裝 cwRsyncServer

http://www.linuxidc.com/Linux/2014-08/105514.htm

linux 安裝rsync

[root@nginx ~]# cd /usr/src/  
[root@nginx src]# ll  
total 16  
drwxr-xr-x 2 root root 4096 Jan 26  2010 debug  
drwxr-xr-x 2 root root 4096 Jan 26  2010 kernels  
[root@nginx
src]# wget http://rsync.samba.org/ftp/rsync/src/rsync-3.0.9.tar.gz [root@nginx src]# tar zxvf rsync-3.0.9.tar.gz [root@nginx src]# cd rsync-3.0.9 [root@nginx rsync-3.0.9]# ./configure --prefix=/usr/local/rsync [root@nginx rsync-3.0.9]# make [root@nginx rsync-3.0.9]# make install

密碼檔案

[root@nginx
rsync-3.0.9]# cd /usr/local/rsync/ [root@nginx rsync]# echo "rsync-pwd" >/usr/local/rsync/rsync.passwd

許可權

chmod 600 rsync.passwd 

修改inotify_start.sh指令碼

#!/bin/bash  
host=192.168.10.221  
src=/tmp/         
des=web 
user=webuser 
/usr/local/inotify/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M'
--format '%T %w%f%e' -e modify,delete,create,attrib $src \ | while read files do /usr/bin/rsync -vzrtopg --delete --progress --password-file=/usr/local/rsync/rsync.passwd $src $user@$host::$des echo "${files} was rsynced" >>/tmp/rsync.log 2>&1 done

ok了

refurl

http://blog.csdn.net/linuxlsq/article/details/51768731

http://www.ttlsa.com/web/let-infotify-rsync-fast/