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
 
 
 
 

你可能感兴趣的:(rsync,文件同步,inotify-tools, )