svn 同步鏡像:svnsync
源:http://192.168.1.100/svn/hunt/
目標:file:///data/hunt/svn_backup/Project01/
方法:
目標端:
1、創建項目:
svnadmin create /data/hunt/svn_backup/Project01/
2、改pre-revprop_change
進入到hooks目錄,
cp pre-revprop-change.tmpl pre-revprop-change
chmod 755 pre-revprop-change
echo "exit 0" >pre-revprop-change
3、初始化
復制相應的conf文件到對應的目錄下,如user.conf、authz等
svnsync init file:///data/hunt/svn_backup/Project01/ http://192.168.1.100/svn/hunt/
語法:svnsync init 目標端svn目錄 源端svn目錄
同步過程會要求輸入root密碼,隨便輸入,然后是svn用戶/密碼,正常會顯示如下內容:
Copied properties for revision 0.
4、執行同步
svnsync sync file:///data/hunt/svn_backup/Project01/ --username admin --password admin
過程會顯示如下內容:
Transmitting file data .
Committed revision 1.
Copied properties for revision 1.
Transmitting file data .
Committed revision 2.
Copied properties for revision 2.
Transmitting file data .
Committed revision 3.
Copied properties for revision 3.
...
源端:
1、修改post-commit:
cp post-commit.tmpl post-commit
chmod 755 pre-revprop-change
把 post-commit 中,最后兩行替換為
svnsync sync --non-interactive file:///data/hunt/svn_backup/Project01/ --username admin --password admin
注意:
svnsync過程可能因網絡問題導致同步失敗,報以下錯誤:
Failed to get lock on destination repos...
此時可能被加鎖了,更改鎖:
svn propdel svn:sync-lock --revprop -r 0 file:///data/hunt/svn_backup/Project01/(目的同步庫)