Monday, November 29, 2010

How to migrate an SVN repository

I had a chance to migrate an SVN repository of more than 10,000 revisions to another machine. Here are the process and the problems I solved.

1. Install a new Subversion server
CollabNet Subversion Edge 1.3 for Windows 64-bit is chosen because it has great web user interface to manage repositories and users.

2. Dump old repository
This should be very easy by using
svnadmin dump path/to/repository > repository.dump

But I got errors like
svnadmin: Filesystem path .../trunk/... is neither a file nor a directory

This is because either the file system or the repository is corrupt. I had to spit the dumping at the failing revision. Any dumpings after the failing point should use --incremental option.
svnadmin dump -r 0:N-1 path/to/repository > 0_N-1.dump
svnadmin dump --incremental -r N+1:M path/to/repository > N+1_M.dump

3. Create new repository
This can be done in 2 ways.
svnadmin create path/to/repository
or
New Repository in Repositories category in Subversion Edge's web UI (http://host:3343/csvn/repo/create).

Note, however, that you have to uncheck "Create standard trunk/branches/tags structure" in Use template option. Otherwise you will get following error when loading the dumped repository.
adding path : branches ...svnadmin: File already exists: filesystem '..\data\repositories\repository\db', transaction '123-4l', path 'branches'

4. Load dumped repository (for me, repositories)
Remember to use --force-uuid when you load the repository, or you may suffer either the above error or difficulties in relocate you old repository to new one.
svnadmin load --force-uuid path/to/repository < repository.dump

If you have failures in dumping like me. You have to replicate what the failing revision is supposed to be doing, and check in the changes to revision N in my example.

Hope it's helpful to Subversion users, but maybe migrate to Git is the way to go.

No comments:

Post a Comment