Migrating an SVN Project to Different Repository

Following the completion of the development phase of a recent project, we needed to handover the project's source code to the client as part of the project delivery process.

We wanted to capture the project's history, so this would be available to the client's support and maintenance team. Fortunately, subversion provides a dump facility to do just that. Unfortunately, the dump process can produce huge volumes of data, and in our case, the output data was much bigger than the disc space available on the server!

The svnadmin dump command extracts all the data from each checkin and writes it in a fairly verbose format. We use a single repository for all our projects, and always have done, but we may have been better prepared for this delivery if we'd created a separate repository for this particular project.

The first checkin of the project was number 4399. So when I came to do a dump, starting at revision 4399, the dump file would have contained the entire repository including all previous projects. It was this initial dump that caused the disk space problem.

The documentation describes a dump filter tool called svndumpfilter which allows you to selectively include or exclude particular paths in the repository. The examples in the book (http://svnbook.red-bean.com/) show how to use this filter tool, but if you haven't got enough disk space to create the non-filtered dump, then you're stuck.

The solution was that the dumped data can be directed to stdout and the dump filter can read from stdin. When combined with a pipe through gzip, I got the dump I wanted, with only the checkin details needed to migrate the codebase to the client's repository.

The final command looked like this:

svnadmin dump /path/to/svn/repository -r 4399:5196 | svndumpfilter include MyClient/MyProject | gzip > svn-4399-5196.dump.gz

There's one catch worth noting about loading this dump into a new repository: The filter has filtered out the checkin that created the MyClient directory, so I needed to create this directory in the new repository before loading from the the dump file. Without this initial directory, I got this error:

<<< Started new transaction, based on original revision 4399 svnadmin: File not found: transaction '0-1', path 'MyClient/MyProject' * adding path : MyClient/MyProject ...

To perform the load operation, I used this command:

zcat svn-4399-5196.dump.gz | svnadmin load newrepos

This site uses cookies. Continue to use the site as normal if you are happy with this, or read more about cookies and how to manage them.