rsync + inotify-tools 文件同步

 ##################################### rsync + inotify-tools ####################################################################

#debain
apt-get install rsync
apt-get install inotify-tools
 
 
# centos
yum install -y rsync
yum install -y inotify-tools
 
cd /tool
wget https://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
tar zxvf inotify-tools-3.14.tar.gz
cd inotify-tools-3.14
./configure
make
make install
 
#啓動
rsync --daemon --port=873 --config=/etc/rsyncd.conf
 
# rsyncd裏面配置passwd是
#          username:password 這樣的格式
#     客戶端使用的時候,不能用這種格式,文件裏面只能有password
 
###服務端用戶名密碼 156 ,157
chmod 0600 /etc/rsync_pass.pas
root:123456
 
###客戶端密碼 112 
chmod 0600 /etc/rsync_client.pas
123456
 
#客戶端
rsync -vzrtog --delete  --exclude "Logs/"  --exclude "logs/" --exclude "Cache/" --exclude "Temp/" --password-file=/etc/rsync_client.pas /usr/local/webserver/htdocs/ads/Uploads/ [email protected]::www
 
rsync -vzrtog --delete  --exclude "Logs/"  --exclude "logs/" --exclude "Cache/" --exclude "Temp/" --password-file=/etc/rsync_client.pas /usr/local/webserver/htdocs/ads/Uploads/  [email protected]::www
 
 
####### 所有代碼文件推送 ,推送洛陽機房要用聯通ip地址才行 #############################
rsync -vzrtog --delete  --exclude "Logs/" --exclude "config.php" --exclude "logs/" --exclude "Cache/" --exclude "Temp/" --password-file=/etc/rsync_client.pas /usr/local/webserver/htdocs/  [email protected]::www
 
rsync -vzrtog --delete  --exclude "Logs/" --exclude "config.php" --exclude "logs/" --exclude "Cache/" --exclude "Temp/" --password-file=/etc/rsync_client.pas /usr/local/webserver/htdocs/  [email protected]::www
 
 
# 服務端命令 不去不用
rsync -vzrtog --delete  --exclude "Logs/"  --exclude "logs/" --exclude "Cache/" --exclude "Temp/" --password-file=/etc/rsync_client.pas /usr/local/webserver/htdocs/ads/Uploads  [email protected]::www
 
 
 
rsync -vzrtog --password-file=/etc/rsync_client.pas /usr/local/webserver/htdocs/ads/Uploads/ [email protected]::www
 
 
## 數據庫備份後遠程傳輸
rsync -vzrtog --password-file=/etc/rsync_client.pas /usr/local/webserver/mongo/bak/2012-04-22/  [email protected]::www > /temp/rsync.log &
 
rsync -vzrtog --password-file=/etc/rsync_client.pas /usr/local/webserver/mongo/bak/2012-04-22/  [email protected]::www > /temp/rsync2.log &
 
rsync -vzrtog --password-file=/etc/rsync_client.pas /usr/local/webserver/mongo/bak  [email protected]::www &
 
chmod +w /usr/local/webserver/htdocs/ads/Uploads
chown -R www:www /usr/local/webserver/htdocs/ads/Uploads
 
 
 
如果出現這個錯誤“/usr/local/bin/inotifywait: error while loading shared libraries: libinotifytools.so.0”可以採用以下辦法解決:
ln -sv /usr/local/lib/libinotify* /usr/lib/
ln -s /usr/local/lib/libinotifytools.so.0 /usr/lib64/libinotifytools.so.0
cp /usr/lib/libinotifytools.so.0 /usr/local/lib/
 
 
 
 
############### /etc/rsyncd.conf ###############
[root@localhost shell]# cat /etc/rsyncd.conf
uid = root
gid = root
use chroot = no
max connections = 50
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[www]
path = /usr/local/webserver/htdocs/
ignore errors
read only = no
list = false
hosts allow = 122.72.0.156,122.72.0.157,222.88.93.112,61.54.28.22,222.88.76.180,61.158.132.240
hosts deny = *
auth users = root
secrets file = /etc/rsync_pass.pas
 
#######
#rsync
#rsync --daemon --port=873 --config=/etc/rsyncd.conf
 
 
 
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章