rsync 推送

 

两遍服务器都安装好rsync后  若是作推送服务 被推送的服务器的 配置文件 注意事项html

 

 

1服务端(192.168.1.241)配置的密匙文件 格式为【运行环境】

 用户名:密码git

root:123456bash

 

2 客户端(192.168.1.240)配置的密码文件[git代码托管]

密码服务器

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

 inotufy 及时监控git代码修改 并推送到 服务器

/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

 

 

 一键安装包 服务器端 并无安装git命令  若是要在服务器上面使用git 请单独安装 git

yum install -y git

 

参考

  http://www.osyunwei.com/archives/7435.html

相关文章
相关标签/搜索