Moving SVN Repositories

I recently relocated a number SVN repositories to a new hosting provider. To do so I ended up merging ideas from a number of different locations, so here is a quicknote that summarizes the various steps, both for the server & working copies:

 Moving the Repository

On old host:

  1. Dump the entire repository to a file using: svnadmin dump /path/to/repository > repo-name.dmp [1]. Take care, dump outputs to standard output, to avoid seeing lots of gibberish, be sure to redirect the output to a file (using >)
  2. Zip this file to save space (it typically compresses well) using zip repo.zip repo-name.dmp
  3. Rename the old repository to prevent accidentally using it using:

    mv /path/to/repository /path/to/repository-old

On new host:

  1. Transfer the zipped dump file to the new host. This can be done using

    [new_host]$ cd svn_repos_folder
    [new_host]$ sftp user@old.host.com
    stfp> cd path/to/repository
    sftp> get repo.zip
    sftp> exit

  2. Create a new empty repository using svnadmin create repo-name [1]

  3. Extract the dump file using unzip repo.zip

  4. Import the old repository using svnadmin load repository-name --force-uuid < repo-name.dmp [1]. At this point the new repository should be ready to use, with the complete history from the old repository

Updating Working copies

  1. Run svn switch --relocate http://my.original.repository.com/proj1/trunk http://my.new.repository.com/proj1/trunk [2] to convert all old links within the working copy to the new location.

Hint: you can get the old repository URL using svn info

Additional notes for Versions (Mac OSX Subversion client, tested with v1.2.2)

  • Repositories links can be updated by right clicking and selecting “Edit Bookmark.”
  • Working copies are not automatically updated, use the command line instructions above.
  • Verify that the changes are working by exploring the timeline

References

1 http://stackoverflow.com/questions/360758/subversion-move-repository
2 http://rextang.net/blogs/work/archive/2006/05/03/3697.aspx

1 comment

  1. You can also use svnsync to move the repository; that way you can transfer all the data without the need to take the ‘old’ repository down. This is also the only way I know of to get your data from hosted environments, where you don’t have shell access or access to dumping the repository.

Leave a comment

Your email address will not be published. Required fields are marked *