How to Move a SVN Repository

It never hurts us if we have backup in our hand!

This blog reminds me about how to move a svn repository to another server. I always google it when I want to do this; so, making a note here is helpful for me. Just follow these step below:

Step 1:

Create a svn dump file with this backup script:

svnadmin dump /path/to/repository > repo_name.svn_dump

It'll contain all of the revisions you made; so, its size is probably quite large.

Step 2:

Transfer the file to another server and then create a new empty repository in that server by:

svnadmin create /path/to/repository

Step 3:

Import the dump file into this new one:

svnadmin load /path/to/repository < repo_name.svn_dump

That's all we need to do!

What if someone's committing a new version on the old server? We can easily solve this by creating an incremental dump file for the particular revision and import it using this command:

svnadmin dump --incremental -r <# of revision> /path/to/repository > rev<# of revision>.svn_dump

Then import into the new server using this command:

svnadmin load /path/to/repository < rev<# of revision>.svn_dump

By the way, if you have many users using the same svn repository, don't forget to tell them that you've already changed the location. To change the working directory, we can use this command:

svn switch --relocate <old working directory> <new working directory>

Hope this helps! 🙂