svn 同步备份

目标服务器

建立同名版本库

[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

  1. 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。
  2. 中断同步进程,再次同步,出现: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
  3. 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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值