用svnsync 同步备份任意两个svn 版本库

http://jingyan.baidu.com/article/a3761b2b828f381576f9aaa3.html

如用svnsync 同步备份两台机器的svn 。要同步的项目名称:svn_repossvn 版本库1.4 以上源目录: svn://192.168.108.254/svn_repos 同步目标目录: http:// 目标IP:8080/svn/svn_repos/方法:

1. 如果目标目录 存在相同的项目,请先清除,重新建立空项目svnadmin create svn_repos

2. 在 192.168.120.190 ( 目标目录 )-> cendyn 目录下hooks 目录下,建立pre_revprop-change.bat 全部内容只有一行:exit 0如果用拷贝同目录下的pre_revprop-change.tmpl 则必须删除最后三行的内容或替换为只有一行:exit 0 不然下面初始化同步的时候,将停顿.

3. 执行 初始化(在目标目录 )svnsync init http:// 目标IP:8080/svn/svn_repos/ svn://192.168.108.254/svn_repos即svnsync init 目标库 源库 将向你询问登录目标库和源库的用户名和密码,建议为两个库设置相同的用户名及相同的密码正确后,显示Copied properties for revision 0.

4. 执行同步(目标目录 )svnsync sync http:// 目标IP:8080/svn/svn_repos/

5. 更新同步windows 下:在源库的hooks 下面,添加post-commit 脚本可拷贝post- commit.tmpl->post- commit.batset SVN_HOME="C:Install Filessvnserverin" %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 脚本出错,或者无可执行权限,在提交更新时会报错。

错误处理 : 在源端 , 同步用的帐号需要有读权限 , 在目的端同步帐号需要读写权限 . 权限分配合理后 , 基本上就不会出现其他错误 . 如果出现以下列出的之外的错误 , 请先检查一下 svn 服务是否可正常使用 。

比 较常见的错误是 :# svnsync initialize DEST_URI SRC_URI --username cax --password password_for_caxsvnsync: DAV request failed; it's possible that the repository's pre-revprop-change hook either failed or is non-existentsvnsync: At least one property change failed; repository is unchanged这是由于系统中没有 pre-revprop-change 钩子脚本导致的 , 该文件在版本库的 ~/hooks/ 下 , 只需拷贝一份即可 .cp -pf hooks/pre-revprop-change.tmpl hooks/pre-revprop-change如果是 windows 系统 , 还需要清空 pre-revprop-change 的内容 , 并添加后缀为 pre-revprop-change.bat在批处理文件中 , Linux 下 shell 中注释符 # 不能被 batch 正确解释也会重复出现该错误 。

猜你喜欢

转载自hunan.iteye.com/blog/2092455