用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  正確解釋也會重複出現該錯誤 .

相關文章
相關標籤/搜索