码迷,mamicode.com
首页 > 其他好文 > 详细

rsync + inotify 文件同步

时间:2018-11-23 20:35:16      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:create   run   rsync   chmod   ogr   deny   port   form   cti   

rpm -e rsync-3.1.2-4.el7.x86_64 --nodeps rpm -ivh rsync-3.1.2-4.el7.x86_64.rpm 115 服务端,接收文件的地方 echo "web:123" > /usr/local/rsync/rsyncd.passwd vi /etc/rsyncd.conf # /etc/rsyncd: configuration file for rsync daemon mode # See rsyncd.conf man page for more options. uid = root gid = root use chroot = no max connections = 200 timeout = 1000 transfer logging = yes pid file = /var/run/rsyncd.pid lock file = /var/run/rsyncd.lock log file = /var/log/rsyncd.log log format = %t %a %m %f %b port = 873 ignore errors #read only = yes #address = 192.168.248.136 [web] path = /home/dqws_ftp/upload/ read only = false write only = yes hosts allow = xxxxx hosts deny = * list = false auth users = web secrets file = /usr/local/rsync/rsyncd.passwd #read only = yes #exclude = test/ #不同步的目录 cd /usr/local/rsync chmod 600 rsyncd.passwd rsync --daemon echo "/usr/local/rsync/bin/rsync --daemon --config=/usr/local/rsync/rsyncd.conf" >> /etc/rc.local 114 客户端,发送文件的地方 echo "123" > /usr/local/rsync/rsync.passwd cd /usr/local/rsync chmod 600 rsyncd.passwd /usr/bin/rsync -vzrtopg --progress --password-file=/usr/local/rsync/rsyncd.passwd /home/dqws_ftp/upload/ web@xxxxxx::web 删除安装包 rpm -ivh inotify-tools-3.14-8.el7.x86_64.rpm 脚本 #!/bin/bash host=xxxxxx src=/home/dqws_ftp/upload/ des=web user=web /usr/bin/inotifywait -mrq --timefmt ‘%d/%m/%y %H:%M‘ --format ‘%T %w%f%e‘ -e modify,create,attrib $src | while read files do /usr/bin/rsync -vzrtopg --progress --password-file=/usr/local/rsync/rsyncd.passwd $src $user@$host::$des echo "${files} was rsynced" >> /data/logs/rsync.log 2>&1 done

rsync + inotify 文件同步

标签:create   run   rsync   chmod   ogr   deny   port   form   cti   

原文地址:http://blog.51cto.com/12473494/2321304

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!