Moving a Subversion Repository

Sometimes it is necessary to move a subversion repository. In this case, it was because I wanted to consolidate a few subversion repositories into one directory on a dedicated hard drive.

Moving a subversion repository usually consists of two steps:

  1. Moving the repository
  2. Updating the working copy to reflect the repository move

This post will handle both steps.

Move the repository

Instead of actually moving the repository as one would expect, we’re going to backup our existing repository, import out backup into a newly created one.  First we’ll list the commands, then break down what we’re doing.

svnadmin dump /path/to/old-repository > ~/repo.dmp
svnadmin create /path/to/new-repository
(Update file/directory permissions)
(Update repository permissions)
svnadmin load repository-name < ~/repo.dmp
  1. L1: We dump the repository into a backup file.
  2. L2: Create a new repository.
  3. L3: Update file / directory permissions (by using some combination of chown, chgrp and chmod)
  4. L4: Update repository permissions (by editing files like /path/to/new-repository/conf/passwd and /path/to/new-repository/conf/svnserve.conf)
  5. L5: Extract the backup into the new repository.

Update the working copy

Once we’ve moved our repository, we now need to update the working copy so that commits and updates will reference our new repository.

cd /path/to/working-copy
svn info
svn switch --relocate svn://hostname/path/to/old-repository svn://hostname/path/to/new-repository
svn info
  1. L1: We change to the path of the working copy.
  2. L2: Display the path to the old repository through the svn info command.
  3. L3: Switch the working copy’s repository.
  4. L4: Display the path the the working copy’s repository (verify that the switch worked) through the svn info command.

Clean up

Now that we’re done moving the repository, we want to verify the move and clean up.  To verify the move, we can just check the output of the svn info command.  To further verify, we can run svn update to ensure that nothing is updated.

We will probably also want to remove both the old repository and the backup file.  A simple rm -r for the repository and rm for the backup file is fine.

Lastly, its possible that you would want to use a trimmed down set one of these steps. For example, if you didn’t care about keeping the version history and just wanted to move the repository location, you could skip steps 1 and 5 in the first section. Also, if you didn’t care about moving the working directory but just wanted to make a complete copy of the repository including the version history, you could complete the whole second section.

Posted Sunday, January 31st, 2010 under linux, tips and tricks.

2 comments

  1. Cheri Pomeroy says:

    You really do not need to go through all this effort. You can simply do a mv /svn/directory path/reponame /svn/reponame

  2. Thanks for the comment. It may be true that you can simply do a “mv” for the repository, but you will still need to update the working copies to reflect the new repository path.

    Also, I wanted to permanently backup the repository on a DVD, and compressing the dump seemed to result in a smaller filesize than compressing the repo directory itself. I’m not sure this will hold for any repository, so YMMV.

Leave a Reply