SVN從win遷移到Linux上
公司用的SVN環境為 Windows server 2003 ,VisualSVN 2.1.5版本
1.dump出SVN數據並上傳到Linux
在Repositories處先導出其項目名列表,然後編寫一個簡單的bat腳本進行dump:
比如:
@echo off
svnadmin dump C:\Repositories\baijiu > C:/test/baijiu.dump
svnadmin dump C:\Repositories\BAS > C:/test/BAS.dump
把SVN數據備份dump文件及authz和htpasswd文件上傳到Linux
2.Linux安裝SVN
#yum install subversion? 安裝SVN
#mkdir /opt/svn/repositories 建立版本庫目錄
#svnserve –d –r /opt/svn/repositories 啟動SVN
#killall svnserve 關閉SVN
#svnadmin create /opt/svn/repos/baijiu? 建立要遷移的項目庫
#svnadmin create /opt/svn/repos/BAS
#vim /opt/svn/repos/baijiu/conf/svnserve.conf 配置用戶訪問權限
-->?
??? anon-access = none
??? auth-access = write
??? password-db = /opt/svn/passwd
導入數據:
#svnadmin load /opt/svn/repos/baijiu < /home/oldsvnbak/baijiu.dump
#svnadmin load /opt/svn/repos/BAS < /home/oldsvnbak/BAS.dump
歸納以上步驟寫個腳本進行SVN數據遷移:
#!/bin/sh
#svn migration
#2018-5-23
# [email protected]
#create and import svn-project
DIRECTORY_HOME="/home/oldsvnbak"??????? #存放dump文件目錄
projects=`cat /home/mytmp/reposlist.txt`? #項目庫名列表
#create svn-Repositories
for project in $projects;
do
??? svnadmin create $SVN_HOME/$project
done
#reset svnserve.conf
find $SVN_HOME -name svnserve.conf -exec cp /home/mytmp/svnserve.conf {} \;
#import oldsvndata
for project in $projects;
do
??? echo "....start load $project ........................"
??? sleep 3
??? svnadmin load $SVN_HOME/$project < $DIRECTORY_HOME/$project.dump
??? echo "....end load ..................................."
??? sleep 3
done
編寫了一個SVN的重啟腳本:
[root@svn svn]# cat restartsvnserve.sh
#!/bin/sh
#restart the svn-serve
#2018-5-23
#[email protected]
#kill old serve
killall svnserve
#start new serve
svnserve -d -r /opt/svn/repos
[root@svn svn]#
需要註意的坑:
從win上導出的項目庫名列表,上傳到Linux會有編碼問題,會導致腳本運行時報錯,說找不到庫名字
需要重新編寫項目庫名列表,在Linux上重新創建reposlist.txt文件,復制粘貼即可!
SVN從win遷移到Linux上