svnsync 实现版本库同步备份
准备SVN环境主从:
172.10.3.244(主)
172.10.3.188(从)
1、在172.10.3.244主SVN上建立版本库
mkdir -p /opt/svn
建立4个仓库java、php、ios、android
svnadmin create /opt/svn/java
svnadmin create /opt/svn/php
svnadmin create /opt/svn/ios
svnadmin create /opt/svn/android
配置每个仓库的conf下authz,passwd,svnserve.conf对应的文件 。
举例:vim /opt/svn/java/passwd
[users]
# harry = harryssecret
# sally = sallyssecret
wangj=456
vim /opt/svn/java/authz
[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average
[groups]
java=wangj
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[java:/]
@java=rw
vim /opt/svn/java/svnserve.conf
anon-access=none
auth-access=write
password-db = passwd
authz-db = authz
realm = /opt/svn/java
2、在要备份的机器上(172.10.3.188)建立版本库与主的路径一样。
mkdir -p /opt/svn
建立4个仓库java、php、ios、android
svnadmin create /opt/svn/java
svnadmin create /opt/svn/php
svnadmin create /opt/svn/ios
svnadmin create /opt/svn/android
进入ios仓库
cd /opt/svn/ios
创建pre-revprop-change文件
cp pre-revprop-change.tmpl pre-revprop-change
修改pre-revprop-change权限,更改为755
chmod 755 pre-revprop-change
修改pre-revprop-change内容
vim pre-revprop-change
echo "Changing revision properties other than svn:log is prohibited" >&2
exit 1改为 0
在备份机器上执行同步初始化操作
svnsync init file:///opt/svn/ios svn://172.10.3.244/ios --username wangj --password 123
执行后出现以下信息
Copied properties for revision 0.
3、在主机器上(172.10.3.244)更改post-commit
cd /opt/svn/ios/hooks
cp post-commit.tmpl post-commit
把post-commit中,最后一行加
svnsync sync --non-interactive svn://172.10.3.188/java --username wangj --password 123
更改post-commit权限
chmod 755 post-commit
4、备份机器(172.10.3.188)执行同步操作
svnsync sync svn://172.10.3.188/ios --username wangj --password 123