How to Move a Subversion Repository

I recently had to move our main Subversion repository to a new server the other day, so I thought I would pass along this quick how-to.

To move a Subversion repository from one system to another you only have to enter a couple of easy subversion commands. To start, go to the source system and at a command prompt or terminal window type:

svnadmin dump /path/to/repository > repository-name.dmp

If the dump file is rather large you can compress it with your favorite zip utility. Now you need to get the dump to your new server, so simply transfer the file via FTP, local share, CD, thumbdrive or whatever it takes.

Once the dump file is on the new machine and uncompressed, you need to set up and load the new repo by typing:

cd /path/to/new-repository
svnadmin create repository-name
svnadmin load repository-name< repository-name.dmp

A couple of small things to note - the dump file will be rather large as it represents every commit made on your repository. If your repository is rather large and mature, this file could get quite large. Also this method works across platforms so moving from UNIX to Windows or visa-versa is also possible.

18 Responses to “How to Move a Subversion Repository”

  1. Ken said on October 3rd, 2006 at 12:01 pm

    Thank you, Jim, for the concise and accurate “How to move a subversion repository”.

  2. bryan said on January 29th, 2007 at 10:11 pm

    thanks, it works :)

  3. Dan Wang said on February 20th, 2007 at 4:10 pm

    I tried this procedure on Windows XP and everything works up till the point of svnadmin load. I can see on the DOS console the different revisions being sucked in. However, if I try a svn checkout from the newly loaded repository, the system keeps complaining that the repository is not found.
    I check and find that under the db subdirectory, there are a number of revisions as I expected.
    Any suggestions?

  4. Kris Bravo said on February 24th, 2007 at 6:56 pm

    May want to mention how to beging using the new location if you already have a working copy checked out & the url changed.

  5. Eric said on March 17th, 2007 at 10:46 pm

    This tutorial is great, however, I think the change directory step is not necessary, it can be simplified as:

    svnadmin create new-repository-path
    svnadmin load new-repository-path

  6. Larry Rubin said on May 8th, 2007 at 7:59 pm

    Worked like a charm. Thanks!

    If you’re using svn w/ trac you will need to a) update your trac conf to point to the new repo location, and b) resync trac

  7. Koz said on July 17th, 2007 at 4:19 pm

    Wicked, this is brilliant, saved my butt cheerz

  8. Polymorphic Podcast : Podcast: Subversion Quickstart for .NET Developers said on August 9th, 2007 at 7:05 am

    [...] [...]

  9. roger pack said on August 9th, 2007 at 8:38 pm

    To decrease the size you can create a dump of only diffs, too :)

  10. Mario said on September 19th, 2007 at 11:52 am

    If you want to move only one project in a repository, you might need to remove or delete the other projects. You can do this by running svndumpfiler on your new dumpfile. Instead of actually deleting a project, you’ll be filtering it out of your repository history.

    See this link for the options that are available. You can either include certain files or chose to exclude them. I’d recommend removing empty revisions, but you might not want renumber your revision if you use them as reference points often.

    If you’re working from windows, you’ll need to use a shell redirect instead of the cat and pipe.

    svndumpfilter include project1 project1-dumpfile

  11. Mario said on September 19th, 2007 at 11:55 am

    If you want to move only one project in a repository, you might need to remove or delete the other projects. You can do this by running svndumpfiler on your new dumpfile. Instead of actually deleting a project, you’ll be filtering it out of your repository history.

    See this link for the options that are available. You can either include certain files or chose to exclude them. I’d recommend removing empty revisions, but you might not want renumber your revision if you use them as reference points often.

    If you’re working from windows, you’ll need to use a shell redirect instead of the cat and pipe.

    svndumpfilter include project1 <repos-dumpfile >project1-dumpfile

  12. Al said on September 27th, 2007 at 12:35 am

    I needed to move my repository to a raided drive on the same system, so I just stopped the SVN service, copied the files to my new drive. I deleted the old SVN service and created a new service with the path to the new repository location. It seems to be working fine. The reason I did this is because I have quite a few projects that I keep as separate repositories, so it would’ve been painful to move each and everyone of them (20+). Also, recreating the project on the same server, would mean that I’d have to deal with renaming things, etc., etc.

  13. links for 2007-10-27 « dstelow notes… said on October 27th, 2007 at 5:26 pm

    [...] How to Move a Subversion Repository (tags: dev sourcecontrol svn opensource) [...]

  14. mark said on December 12th, 2007 at 12:03 pm

    You can also pipe to the unix command “split” instead of directly outputting to a file

    svnadmin dump /var/lib/svn/repositories/repo_name | split -b 700m - mysvnproj.dump.tar.gz

    This will give you 700 megabyte tar.gz files with the extension “tar.gzaa”, “tar.gzab”, etc. (note the space dash space to read from the pipe) You can add an extra dot if you want. Then, at your other server:

    cat mysvnproj.dump.tar.gz* | svnadmin load /var/lib/svn/repositories/repo_name

    Do this after creating your new repo as per the original article.

  15. Abbas said on January 17th, 2008 at 12:44 pm

    Thanks for the info! It worked like a charm and saved me time. People on the internet - you are just great!

  16. Brandon said on April 8th, 2008 at 12:34 am

    It is sometimes convenient to do transfers through ssh, like tar or svn dumps — as long as you aren’t going to have a problem with the transfer being interrupted.

    The following command will make the destination local repository, then
    ssh to the remote repository source, and
    dump the repository through gzip, whilst piping (stdout) it through the ssh connection…
    …back to localhost where the stream is uncompressed and piped into svnadmin to load it.

    svnadmin create reponame && ssh user@source_host “svnadmin dump /path/reponame | gzip -c” | gunzip -c | svnadmin load /dest_path/reponame

    If the local repository has already been made this whole command will refuse to work. You can change the && to a semicolon ; if you wish it to perform the transfer regardless of the destination repository’s existence. svnadmin load can apparently load into a non-empty repository.

  17. Chandrala said on April 28th, 2008 at 11:00 pm

    Hi..

    I tried the steps mentioned above.But didnt work.Tried Al’s Fix as well..didnt work either…:( What am I doing wrong?)Plz help..

  18. Amy Thomas said on June 3rd, 2008 at 2:01 pm

    How can I move source repository code that is in under one path to a different path.
    Right now I have code under say,/data/MyStuff/Projects/proj1 I would like to move proj1 to
    /data/Other/NewProjects/proj1.
    Is this a complex task?
    Thanks