公司用的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
??? authz-db = /opt/svn/authz
??? 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
# linx@jmtop.com
#create and import svn-project
DIRECTORY_HOME="/home/oldsvnbak"??????? #存放dump文件目录
SVN_HOME="/opt/svn/repos"?????????????????????????? # 版本库目录
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
#linx@jmtop.com
#kill old serve
killall svnserve
#start new serve
svnserve -d -r /opt/svn/repos
[root@svn svn]#
需要注意的坑:
从win上导出的项目库名列表,上传到Linux会有编码问题,会导致脚本运行时报错,说找不到库名字
需要重新编写项目库名列表,在Linux上重新创建reposlist.txt文件,复制粘贴即可!
原文地址:http://blog.51cto.com/xaverlin/2121068