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 thoughts on “How to Move a Subversion Repository”

  1. 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?

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

  3. 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

  4. 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

  5. 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.

  6. 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.

  7. 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.

  8. 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..

  9. 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
    Is this a complex task?

  10. Great brain dump!

    One extra point. If you are moving an entire installation, you will have to manually copy over the authz and passwd files, they don’t get included in the dump.

Comments are closed.