Moving your subversion repository

Every now and then there comes a time when you will need to move your subversion repository.  Fortunately it's actually very easy....

First you will want to backup your old repository.

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

This may take quite a while depending on how many revisions you have and how large they were.  This file will probably be quite large as it obviously contains the diffs across your repository from when you created it.

Create a new repository on the destination server

svnadmin create /path/to/repository

Now import the dump file that you created into the new repository.

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

You could also vary this slightly by zipping the file before copying it across to the server.  Simply pipe it into the gzip command.

svnadmin dump /path/to/repository | gzip > repo_name.dump.gz

To undo this you would then run

gunzip -c repo_name.dump.gz | svnadmin load /path/to/repository

Of course if someone has made changes to the repository while you were copying the files across (which is likely given the size) you will need to merge these changes in.  You can create a dump of just the revisions that you are missing.

svnadmin dump /path/to/repository -r 1234:HEAD --incremental > repo_name_updates.dump

Here we took a dump from revision 1234 to the head (final) revision.  The incremental option here is important as it causes the first revision in the dump stream to contain only the files and directories modified in that revision.  Without this your dump file will be quite large again.  Then import that into your new subversion system with the same commad as before.

svnadmin load /path/to/repository < repo_name_updates.dump

You should then have all the revisions on your new system and be ready to start using it with minimal downtime.