使用svnsync备份很简单,步骤如下:
一、在备份机上创建一个空库:svnadmin create SMP
二、更改该库的钩子脚本pre-revprop-change(因为svnsync要改这个库的属性,也就是要将源库的属性备份到这个库,所以要启用这个脚本):
cd SMP/hooks;
cp pre-revprop-change.tmpl pre-revprop-change;
chmod 755 pre-revprop-change;
vi pre-revprop-change;
将该脚本后面的三句注释掉,或者干脆将它弄成一个空文件。
三、初始化,此时还没有备份任何数据:
svnsync init file:///home/backup/svn/svnsync/SMP/ http://svntest.subversion.com/repos/SMP
语法是:svnsync init {你刚创建的库url} {源库url}
注意本地url是三个斜杠的:///
四、开始备份:
svnsync sync file:///home/backup/svn/svnsync/SMP
这是就一个个版本进行备份了。
附录:
可能的报错一:
Failed to get lock on destination repos, currently held by 'bug1.corp.scmbbs.com:0c424c20-2e3b-0410-bd34-7fdd53c25d02'
Failed to get lock on destination repos, currently held by 'bug1.corp.scmbbs.com:0c424c20-2e3b-0410-bd34-7fdd53c25d02'
Failed to get lock on destination repos, currently held by 'bug1.corp.scmbbs.com:0c424c20-2e3b-0410-bd34-7fdd53c25d02'
Failed to get lock on destination repos, currently held by 'bug1.corp.scmbbs.com:0c424c20-2e3b-0410-bd34-7fdd53c25d02'
Failed to get lock on destination repos, currently held by 'bug1.corp.scmbbs.com:0c424c20-2e3b-0410-bd34-7fdd53c25d02'
Failed to get lock on destination repos, currently held by 'bug1.corp.scmbbs.com:0c424c20-2e3b-0410-bd34-7fdd53c25d02'
Failed to get lock on destination repos, currently held by 'bug1.corp.scmbbs.com:0c424c20-2e3b-0410-bd34-7fdd53c25d02'
Failed to get lock on destination repos, currently held by 'bug1.corp.scmbbs.com:0c424c20-2e3b-0410-bd34-7fdd53c25d02'
Failed to get lock on destination repos, currently held by 'bug1.corp.scmbbs.com:0c424c20-2e3b-0410-bd34-7fdd53c25d02'
Failed to get lock on destination repos, currently held by 'bug1.corp.scmbbs.com:0c424c20-2e3b-0410-bd34-7fdd53c25d02'
svnsync: Couldn't get lock on destination repos after 10 attempts
这个时候可能属性被锁了,删掉属性:
svn propdel svn:sync-lock --revprop -r0 file:///home/backup/svn/svnsync/SMP
删除成功后,再试一遍基本就可以了。
如果反复操作都是同样错误的话,有可能是你的svn安装的有问题,重新安装一遍就好了,俺就是这样。
可能报错二、
svnsync: REPORT request failed on 'http://svn1.subversion.com/repos/Relevance'
svnsync: The requested report is unknown.
这是因为你源库的版本太低了,svnsync所需要的函数Report是svn1.4后加入的。没办法,对你的库进行升级后才能备份。
由于执行svnsync sync file:///home/backup/svn/svnsync/SMP 过程中容易出现错误一,避免中途人工干预,我写了一个脚本,来自动修复错误。脚本里面的路径自己来修改吧,我的环境是本地备份到另外一个硬盘。
[root@smb svn_bak]# cat svnsync.sh
#!/bin/bash
while (:)
do
svnsync sync file:///svn_bak/svnbak/
if [ $? != 0 ]
then
svn propdel svn:sync-lock --revprop -r0 file:///svn_bak/svnbak/
fi
sleep 60
done