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

 

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


如用svnsync  同步备份两台机器的svn 。shell

要同步的项目名称:svn_repos  windows

svn  版本库1 。4 以上
源目录:            svn://192.168.108.254/svn_repos    
同步目标目录:      http://    目标IP:8080/svn/svn_repos/    svn

方法: post

1. 若是目标目录 存在相同的项目,请先清除,从新创建空项目
    svnadmin create svn_repos    spa


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


3.  执行 初始化(在目标目录 )
    svnsync init http://  目标IP:8080/svn/svn_repos/ svn://192.168.108.254/svn_repos    get

即svnsync init  目标库 源库
将向你询问登陆目标库和源库的用户名和密码,建议为两个库设置相同的用户名及相同的密码正确后,显示
Copied properties for revision 0.  同步

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

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 脚本出错,或者无可执行权限,在提交更新时会报错

 

错误处理 : 在源端 ,  同步用的账号须要有读权限 ,  在目的端同步账号须要读写权限 .  权限分配合理后 , 基本上就不会出现其余错误 . 若是出现如下列出的以外的错误 ,  请先检查一下 svn  服务是否可正常使用 . 比较常见的错误是 : # svnsync initialize DEST_URI SRC_URI --username cax  --password password_for_cax svnsync: DAV request failed; it's possible that the repository's pre-revprop-change hook either failed or is non-existent svnsync: 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  正确解释也会重复出现该错误 .

相关文章
相关标签/搜索