svnsync
主机:192.168.20.153
从机:192.168.20.167
在两台机操作
上面创建svn仓库
cd /data/svn
svnadmin create repos1
cd repos1
cd conf
修改conf/svnserve.conf
[root@ repos2]$ grep -v "^#" conf/svnserve.conf| grep -v "^$"
[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
realm = repos2
[sasl]
修改conf/authz
[aliases]
[groups]
admin = laiyuzhou
[/]
@admin = rw
修改conf/passwd
[root@ repos2]$ grep -v "^#" conf/passwd| grep -v "^$"
[users]
laiyuzhou = laiyuzhou
启动svn
svnserve -d -r /data/svn
从机上操作
cp hooks/pre-revprop-change.tmpl hooks/pre-revprop-change
echo -e '#!/bin\/bash \nexit 0' > hooks/pre-revprop-change
chmod 755 hooks/pre-revprop-change
============================================================
主机上操作(从机上也行应该)
每次提交后自动同步
cp hooks/post-commit.tmpl hooks/post-commit
echo -e '#!/bin/sh\n var=$(whereis svnsync)\necho $var\nSVNSYNC=$(echo $var | awk '{printf $NF}')\n$SVNSYNC sync --non-interactive svn://192.168.20.167/repos1 --username laiyuzhou --password laiyuzhou' > hooks/post-commit
chmod 755 hooks/post-commit
初始化
svnsync init svn://192.168.20.167/repos1 svn://192.168.20.153/repos1
[root@localhost repos1]# svnsync init svn://192.168.20.167/repos1 svn://192.168.20.153/repos1
Authentication realm: <svn://192.168.20.153:3690> repos1
Password for 'root':
Authentication realm: <svn://192.168.20.153:3690> repos1
Username: laiyuzhou
Password for 'laiyuzhou': *********
.
.
.
Copied properties for revision 0.
同步
svnsync sync --non-interactive svn://192.168.20.167/repos1
可能出现的报错
exit code 250 ---->文件没有权限 chmod 755 file
没有日志、同步后只有版本没有数据 ---->anon-access = none 没设置好
post-commit中svnsync用不了 ----> 使用svnsync的绝对路径/usr/bin/svnsync(whereis svnsync) 代替svnsync