Steve Smith's Blog

Musings on Software and the Developer Community

Moving SVN Repositories to new Server

Recently I had to move some SVN repositories from one server to another.  Here are the steps that worked for me, courtesy of Pete Freitag:

Step 1: Back up SVN Repository

Back up your existing repository with the following command.  Note that if you are using VisualSVN Server as I blogged about previously, you should be able to right-click within the VisualSVN server manager and get a command prompt that will have the correct paths and such to do this:

svnadmin dump /path/repositoryfolder > repositoryname.svn_dump
Notice the ‘>’ and its direction.  It’s important.

Step 2: Create New SVN Repository (on new server)

Next create a new repository.  You can issue this command or just use VisualSVN Server Manager.  If you do the latter, don’t check the box to create a default structure.

svnadmin create /path/repositoryname

Step 3: Import your SVN Repository from its Dump

Issue the following command on the new server from an SVN command prompt:

svnadmin load /path/repositoryfolder < repositoryname.svn_dump

That’s all there is to it.  If you use VisualSVN to look at the repository as it is in mid-load, you may need to refresh it after the load is complete.  Otherwise, you may panic when you see the load is done but only some of your repository has been restored.  Don’t ask how I know this.

I didn’t have to worry about this, but Pete also has info on what to do if someone commits to the old location while you’re in mid-move.  My recommendation is to shut down the old location’s server (or set the specific repository’s permissions to just Everyone : No Access).  The whole move with the above steps should require less than 15 minutes (unless transferring the files takes you longer than this due to their size and/or your bandwidth).

What about my Working Copies?

Of course, once the server is moved and you’ve shut down access to the old location, what do you do with your existing working copies that are linked to the old location?  There are two options:

  1. Relocate.  If you are using TortoiseSVN (and I’m sure there’s a command line tool for this as well, but I’m using Tortoise), you can simply right-click on your existing working copy folder and select TortoiseSVN –> Relocate.  In the dialog that comes up, enter the new location of the repository, and click OK.  Assuming nothing has changed since you moved the repository, this should take just a few seconds to complete.  This is the safer, recommended approach.
  2. Delete and Re-Checkout.  Assuming you checked in everything you cared about before the move, you can simply delete your working copy and then re-fetch it using SVN Checkout.  This is kind of the brute force approach and is not recommended if you have any work in progress!

    kick it on DotNetKicks.com

Monday, 15 February 2010

Comments

 avatar

Aaron Seet said on 16 Feb 2010 at 10:14 AM

actually i just shutdown the SVN service on the old server and copy the repo directories wholesale to the new server.

yea i'm lazy but it works. :-)


 avatar

Steve Smith said on 16 Feb 2010 at 4:02 PM

@Aaron,

I read there might be issues with that if the server configuration and/or SVN version was different, which is why I went down the dump/load route.


 avatar

Aaron Seet said on 16 Feb 2010 at 8:44 PM

Possibly, but the first time i moved from the very old raw Subversion server to VisualSVN, i simply copied the repository directories over as well. :-)

As far as i know the standard FSFS database format has not changed much so moving the directories wholesale should have no ill effects, as far as I have used it. But yes, play safe if your repositories are valuable; make multiple backups of different forms.


 avatar

vel said on 20 Apr 2010 at 2:32 AM

Hi, my svn repository is in live.but Drive size 200GB is going to full.so i am added 500GB Hard disk in same system.How to move my svn repository one drive to another drive (ex:E drive to G drive).please help me,Thanks in advance,Vel


 avatar

fooboo said on 29 Apr 2010 at 7:53 AM

I've set up svn on a new server and copied a dump over from my previous install but when I try to use the new install I get one of two errors depending on what I put in the "Directory" lines in the httpd.conf file.

If I just add the url I get "Repository moved permanently to '<my domain>/repos/"; please relocate

If I add the /repos directory to the end of the lines I get "403 forbidden".

Have you any tips on what I need to change where to make this repository work?

I'm guessing it's a permission thing but I installed svn following a tutorial so I don't want to go changing the wrong directory permission and wrecking it :P


 avatar

fooboo said on 29 Apr 2010 at 9:45 AM

Yey, I found the answer.

You can't call your "Location" virtual directory the same thing as your actual directory. I have a folder called repos and I was appending /repos to my domain. Once I changed the location to /repo all worked fine.


 avatar

Salil Puri said on 12 Jul 2010 at 11:30 AM

I installed VisualSVN Server 2.1 . I have made my repository on shared LAN folder. I was able to install it without any problem and I have been able to import all existing repositories I had on my local machine. The issue I am facing is while creating a new repository if I check the option of create folder structure i get an error!.. IT says 'Cannot find environment variable PATH. The system could not find environment option that was entered' . The repo gets created but without folder structure and i cannot even add any folder using 'create folder' in the context menu.

I have created an environment variable PATH on my local machine and pointed it to the BIN folder inside VisualSVN . Please help me run Visual SVN properly so that i can make repo with folder structure also. Do i need to have some PATH variable in the machine i have my repository in ??.


Leave a Comment

Please join the discussion and share your thoughts.