目标服务器
建立同名版本库
[shell]cd /var/lib/svn
svnadmin create chs
chown -R www-data:www-data chs[/shell]
配置hook/pre-revprop-change
[shell]
cd /var/lib/svn/chs/hooks/
vi pre-revprop-change #输入文件内容
chmod +x pre-revprop-change #执行权限
[/shell]
pre-revprop-change文件内容:
[shell]
#!/bin/sh
exit 0;
[/shell]
同步服务器
初始任务
[shell]
#svnsync init [目标服务器] [源服务器]
svnsync init http://www.onoboss.com/svn/chs http://192.168.1.81/svn/chs
[/shell]
执行同步
[shell]
#svnsync sync [目标服务器]
svnsync sync http://www.onoboss.com/svn/chs
[/shell]
5. 更新同步
windows 下:
在源库的hooks 下面,添加post-commit 脚本
可拷贝post- commit.tmpl->post- commit.bat
set SVN_HOME="C:\Install Files\svnserver\bin"
%SVN_HOME%\svnsync sync --non-interactive http://192.168.120.190:8080/svn/cendyn --username R00130 --password 123
linux 下:
在源库的hooks 下面,添加post-commit 脚本
可拷贝post-commit.tmpl 即
cp post-commit.tmpl post-commit
然后
把 post-commit 中,最后两行替换为
svnsync sync --non-interactive http://192.168.108.187:8080/svn/svn_repos/ --username edison --password edison
即提交更新后,即执行同步命令,不进行交互
把post-commit 设为755 权限。
ps :
如果post-commit 脚本出错,或者无可执行权限,在提交更新时会报错
FAQ
- svnsync: DAV request failed; it’s possible that the repository’s pre-revprop-cha
nge hook either failed or is non-existent
svnsync: At least one property change failed; repository is unchanged
svnsync: Error setting property ‘sync-lock‘:
could not remove a property
答:目标服务器未设置hook/pre-revprop-change,或者目录权限未更改为www-data。 - 中断同步进程,再次同步,出现:Failed to get lock on destination repos, currently held by ‘wonder:83edc72d-1b3c-4531-815a-b80bf58efe07′ 错误。
答: svn propdel svn:sync-lock –revprop -r 0 http://www.onoboss.com/svn/chs - svnsync: Destination HEAD (1021) is not the last merged revision (1019); have you committed to the destination without using svnsync
答:svn propset –revprop -r0 svn:sync-last-merged-rev 1021 http://www.onoboss.com/svn/chs