Tuesday, February 5, 2008

Moving SVN repository to another machine

SVN is a great tool for collaborated programmer to keep every copy files up to date and track changes made by everyone. In my case, I use SVN for synchronize my working file between my workstation and portable one. If you haven't get the SVN installed, follow the instruction given from the SVN site. For Ubuntu user (like me) there's a useful instalation guide here.
Since it's a collaboration tool across the internet, SVN repository supposed can be move from one server to another. Even the server are using different OS. First, you need to dump current repository to a dump file (assummed you have existing repo at /opt/svn/svnrepo/) :

$svnadmin dump /opt/svn/svnrepo > svnrepo.dump

Make the file smaller by compressing it :

$tar -cvzf svnrepo.tar.gz svnrepo.dump

Then transfer the file to new server using SCP (assummed your SSH using different port number 222) :

$scp -P 222 svnrepo.tar.gz username@server2:/home/username/

Once transferred, login to server2 :

$ssh username@server2 -p 222


Extract the dump file and copy to new location (assummed at /opt/svn/svnrepo/)

$tar -xvzf svnrepo.tar.gz
$mkdir /opt/svn/
$mv svnrepo.dump /opt/svn/

Import dump file into running SVN server :

$svnadmin create svnrepo
$svnadmin load svnrepo < face="verdana">Once you complete the step, you can delete the .dump file and the tar.gz file as well.
When running the SVN server make sure it loads repo from the location we just imported by

$svnserve -d -r /opt/svn/svnrepo/

Dont forget on SVN client side, make sure to relocate repo to new location as well

No comments: