- Rsync配置
1.1. 配置文件
vim /etc/rsyncd.conf
uid = root
gid = root
use chroot = no
address = xx.xx.xx.11
port = 873
strict modes = no
max connections = 0
pid file = /home/rsync/rsyncd.pid
lock file = /home/rsync/rsync.lock
log file = /home/rsync/rsyncd.log
exclude = lost+found/
hosts allow = xx.xx.xx.10
ignore errors
read only = no
list = no
[git]
path = /gitlabdir/git-data
comment = git
auth users = git
secrets file = /etc/git.password
[gitlab-psql]
path = /gitlabdir/postgresql
comment = postgresql
auth users = gitlab-psql
secrets file = /etc/psql.password
[backups]
path = /gitlabdir/backups
comment = backups
auth users = git
secrets file = /etc/git.password
[secret]
path = /etc/gitlab
comment = secret
auth users = root
secrets file = /etc/git.password
1.2. 配置密码文件
/etc/git.password
git:xxx123
/etc/psql.password
gitlab-psql:xxx123
mkdir -pv /home/rsync/
1.3. 启动rsync
/usr/bin/rsync --daemon
- Sersync配置
vim backups.xml
<?xml version="1.0" encoding="UTF-8"?>
<head version="2.5">
<host hostip="localhost" port="8008"></host>
<debug start="false"/>
<fileSystem xfs="false"/>
<filter start="false">
<exclude expression="(.*)\.svn"></exclude>
<exclude expression="(.*)\.gz"></exclude>
<exclude expression="^info/*"></exclude>
<exclude expression="^static/*"></exclude>
</filter>
<inotify>
<delete start="true"/>
<createFolder start="true"/>
<createFile start="true"/>
<closeWrite start="true"/>
<moveFrom start="true"/>
<moveTo start="true"/>
<attrib start="false"/>
<modify start="false"/>
</inotify>
<sersync>
<localpath watch="/gitlabdir/backups">
<remote ip="xx.xx.xx.11" name="backups"/>
</localpath>
<rsync>
<commonParams params="-artuz"/>
<auth start="true" users="git" passwordfile="/etc/git.pas"/>
<userDefinedPort start="true" port="873"/><!-- port=874 -->
<timeout start="true" time="1800"/><!-- timeout=100 -->
<ssh start="false"/>
</rsync>
<failLog path="/tmp/rsync_fail_log.sh" timeToExecute="30"/><!--default every 60mins execute once-->
<crontab start="false" schedule="600"><!--600mins-->
<crontabfilter start="false">
<exclude expression="*.php"></exclude>
<exclude expression="info/*"></exclude>
</crontabfilter>
</crontab>
<plugin start="false" name="command"/>
</sersync>
<plugin name="command">
<param prefix="/bin/sh" suffix="" ignoreError="true"/> <!--prefix /opt/tongbu/mmm.sh suffix-->
<filter start="false">
<include expression="(.*)\.php"/>
<include expression="(.*)\.sh"/>
</filter>
</plugin>
<plugin name="socket">
<localpath watch="/opt/tongbu">
<deshost ip="192.168.138.20" port="8009"/>
</localpath>
</plugin>
<plugin name="refreshCDN">
<localpath watch="/data0/htdocs/cms.xoyo.com/site/">
<cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/>
<sendurl base="http://pic.xoyo.com/cms"/>
<regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>
</localpath>
</plugin>
</head>
这个配置文件其实就是对原始命令进行了转化
1.2. 密码文件配置
vim /etc/git.pas
xxx123
1.3. 启动sersync
/usr/local/sersync/sersync2 -d -r -o /usr/local/sersync/backups.xml
PS:
注意密码文件的权限600,不是就要修改,否则报错
chmod 600 /etc/git.pass