How to move a subversion repository

Saturday 30 December 2006This is close to 18 years old. Be careful.

This is how to move a Subversion repository from one place to another. It’s one of those operations I undertake only infrequently, and so have to re-learn each time. This time, I’m writing it down. In this example, I’m converting a file-based repository to a server-hosted one.

  1. Make sure your working directory is fully checked-in to subversion, and back it up, just in case.
  2. Dump the subversion repository. This is done with an svnadmin command:
    svnadmin dump c:\svn\foobar | gzip -9 - > foobar.dump.gz
    It will show progress as it dumps each revision to the dumpfile.
  3. Create the new subversion repository, however it is that you usually do that. In my case, I use the Subversion control panel at Dreamhost.
  4. Copy the foobar.dump.gz file up to the server.
  5. Load the dumpfile into the new repository:
    zcat foobar.dump.gz | svnadmin load foobar
    It will show even more verbose progress than dump did, as it rebuilds the repository transaction by transaction.
  6. Checkout the new repository to a scratch directory:
    svn co http://svn.whatever.com/foobar
  7. Examine the new scratch directory and your current working directory. Make sure the files are the same, to check that the right content is correctly ensconced in your new repository.
  8. If all is well, you can switch your working directory to the new repository:
    svn switch --relocate file:///c:/svn/foobar http://svn.whatever.com/foobar

Enjoy your new repo.

Comments

[gravatar]
Be sure to manually copy over any configuration files -- like conf/svnserve.conf, if you've modified it, and a password file; also be sure to copy over any active hooks.
[gravatar]
Are you sure all of that is needed? Can't you just upload the 'foobar' directory to the server?
[gravatar]
me: that's a good tip. I've never used those features, so I didn't need to copy them, but that would certainly be important.

Justin: I don't know if Subversion guarantees the repos are the same from one version to another. I may have a more recent version on my machine that the server does. The dumpfile is the guaranteed way to move contents around. Maybe I'm wrong, but this works.
[gravatar]
In the early days of subversion (maybe a few years ago), it was pretty common to get bitten by version skew in the repository formats. The only backend storage option was based on BerkeleyDB, and any version change in that library resulted in a repo you could no longer read. I know this ruined my day more than once after an upgrade.

I think annoyance over the fragility of the BerkeleyDB format drove in part the development of the flat file-based repo format, which is now the default. The flat file repo format is much more stable (though slower), but bad experiences from the bdb-only days have trained us to only trust dump and load.

Continuing that paranoia and always using dump and load is probably a good habit to be in, even if not strictly necessary.
[gravatar]
Obligatory plug for distributed version control systems. If you would move your work into something like Bazaar or Darcs, you could work in a central-repository mode as much as you like, with the added benefit that branching and merging, and moving from place to place, would be trivially easy when you wanted to do them.

http://bazaar-vcs.org/

http://abridgegame.org/darcs/
[gravatar]
I have a windows server as svn server. All of files of the repositories are located in d:\svn, and i have a repository that is growing more than expected, because user activities. My server has other bigger partitions, like e:\. How can i create, for example, the folder e:\svn and move that repository here in the same server, without loosing the version number.

Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
Comment text is Markdown.