两遍服务器都安装好rsync后 若是作推送服务 被推送的服务器的 配置文件 注意事项html
用户名:密码git
root:123456bash
密码服务器
123456app
客户端测试推送到服务器端gitlab
rsync -vzrtopg --delete --progress --password-file=/etc/rsyncd/rsyncd.secrets /var/opt/gitlab/git-data/gitlab-satellites/ranmufei/linksame/ root@192.168.1.241::linksame
环境服务器上面有两个 模块测试
(1) linksamespa
(2) appscode
/usr/local/inotify/rsync.sh orm
#!/bin/sh
srcdir=/var/opt/gitlab/git-data/gitlab-satellites/ranmufei/linksame/ #源服务器地址
dstdir=linksame #241 目标服务器
rsyncuser=root #目标服务器用户名
rsyncpassdir=/etc/rsyncd/rsyncd.secrets #目标服务器密码
dstip="192.168.1.241" #目标服务器ip
for ip in $dstip
do
rsync -avH --port=873 --progress --delete $srcdir $rsyncuser@$ip::$dstdir --password-file=$rsyncpassdir
done
/usr/local/inotify/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e close_write,modify,delete,create,attrib,move $srcdir | while read file
do
for ip in $dstip
do
rsync -avH --port=873 --progress --delete $srcdir $rsyncuser@$ip::$dstdir --password-file=$rsyncpassdir
echo " ${file} was rsynced" >> /tmp/rsync.log 2>&1
done
done
启动
#nohup /bin/bash /root/rsync.sh &
开机自启动
#echo "nohup /bin/bash /root/rsync.sh &" >> /etc/rc.local
监听本机多个文件夹下的文件单首创建监听文件 加入开机启动便可
#!/bin/sh srcdir=/var/opt/gitlab/git-data/gitlab-satellites/ranmufei/linksame/ #源服务器地址 srcdir2=/var/opt/gitlab/git-data/gitlab-satellites/ranmufei/apps/ #源服务器地址 dstdir=linksame #241 目标服务器 dstdir2=apps #241 目标服务器 rsyncuser=root #目标服务器用户名 rsyncpassdir=/etc/rsyncd/rsyncd.secrets #目标服务器密码 dstip="192.168.1.241" #目标服务器ip ##################linksame############### rsync -avH --port=873 --progress --delete $srcdir $rsyncuser@$dstip::$dstdir --password-file=$rsyncpassdir /usr/local/inotify/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e close_write,modify,delete,create,attrib,move $srcdir | while read file do rsync -avH --port=873 --progress --delete $srcdir $rsyncuser@$dstip::$dstdir --password-file=$rsyncpassdir echo " ${file} was rsynced" >> /tmp/rsync.log 2>&1 done
yum install -y git
http://www.osyunwei.com/archives/7435.html