Tuesday, 1 September 2009

Migrating a local repository created with TortoiseSVN to a Subversion server hosted repository

If you have created a repository using TortoiseSVN which you access through the URL 'file:///C:/...' but want to migrate this repository to one which is managed and accessed through subversion & Apache, then the following is what worked for me. I originally started off with just TortioseSVN without a Subversion server as it was really easy to setup and generally an excellent way to get to grips with using a repository. Recently as I have been using it more and more I started to run into limitaions with network drives and accessing the data from other computers (it's made very clear in the TortoiseSVN help file that this would be the case, so it was not a suprise). I decided that it was time to bite the bullet and move everything across to a subversion server which I would access through Apache.
At first I thought there would not be an easy way to get all the data in my TortoiseSVN repository into a new Subversion repository but it turned out it was very straightforward indeed (for me at least)!

The first thing to do is to get your Subversion server up and running with Apache, which I have described here. As TortoiseSVN creates repositories in exactly the same format as Subversion, you can use all the subversion administrator commands on the TortoiseSVN repository as though it were any other Subversion repository:

1/ If your TortoiseSVN repository is not stored on the machine which is running Subversion and Apache make a copy of the repository and save that onto the Subversion machine. All of the following steps need to be done on the machine running Subversion and Apache.

2/ Open up a terminal window (start->run->cmd) and change the directory to the directory which has your TortoiseSVN repository inside it (but not to the respository directory itself). In my case my TortioseSVN  repository directory was strored in the root of my C:\ drive so the path in my terminal window looked like 'C:\'

3/ At the prompt in the terminal window type the following then press enter:
svnadmin dump TortoiseRepository > dumpfile
If your TortoiseSVN repository is not called 'TortoiseRepository' just change the name above to whatever you have called it. If the dump works you should see lots of '*Dumped revision' messages. The 'dumpfile' now contains an entire export of your TortoiseSVN repository and all the revisions, comments etc.

4/ Now change the directory in your terminal window to the directory which has your new repository inside (but not to the respository directory itself). In my case I stored my new subversion repository in the root of my C:/ drive again, so the path in my terminal window looked like 'C:\'. Also, make sure you copy the 'dumpfile' (this could be very large depending on the size of the repository you have dumped to it) which will be stored in the path from '2/' above into this directory.

5/ At the prompt in the terminal window type the following then press enter:
svnadmin load Repository < dumpfile
If your new subversion repository is not called 'Repository' just change the name above to whatever you have called it. If the load works you should get lots of 'adding path' messages. Your new repository now contains all the data which used to live in your old TortoiseSVN repository.

6/ Your old TortoiseSVN repository and the 'dumpfile' can now be deleted or kept as a backup. If you want to access your new repository from the machine which is running Subverion and Apache you can use the folllowing URL in Tortoise 'http://localhost/svn'.

7/ Allthough you are not using the repository you created in TortioseSVN any more, you can of course still use TortoiseSVN as your client to access the data on your Subverison server. I personaly use Tortoise as the client where ever possible as I find it so easy to use and the help file is so good.

If you have any problems have a look at Repository Administration section of the subversion book which goes into this process in some detail. The bit I realy needed to know when starting the above was that you could use the svnadmin comands on the Tortoise created repository. Once you know this the subversion book leads you through it. I hope this helps...

1 comment:

  1. Thanks. This helped me 4 years after it was posted :)

    ReplyDelete