Subversion dumps

If you enjoyed this article, please leave a comment, rss subscribe to my RSS feed and/or follow me on Twitter. Thank you very much!

This week, we just had it. The current provider we pay to host our subversion repositories is just unbearable, and so we decided to move (on) to [Unfuddle][3]. Our reason to move to Unfuddle is that they offer everything we need (and more, e.g. Git), at a pretty good price. I also heard Unfuddle a 100 times when I shopped for a recommendation.

And on top of all the features, they also kick butt at support and for example offered to import our repositories right away. But, has anyone of you tried to dump a subversion repository, ever?

Creating a dump

Being a good user, I rtfm'd first. The manual states to use svnadmin dump. And apparently it's that easy?

Not really.

First off, the manual tells me to: svnadmin /path/to/repo. That didn't work at all though. Instead I had to svnadmin dump /path/to/repo/.svn. But that didn't work regardless.

After rtfm, there's stfw, and I did that too when I encountered the following issues:

server# svnadmin ./path/to/repo/.svn
svnadmin: Expected repository format '3' or '5'; found format '8'

... then I updated my local subversion client, checked out a new copy of the repository, and got this:

server# svnadmin ./path/to/repo/.svn
svnadmin: Can't open file './path/to/repo/.svn/format', no such file or directory

There really is no format file when I check out the same repository with Subversion 1.6.3.

Ahhhh!!!111 Madness!

Apparently a more recent version of Subversion cannot deal older repositories?

Updated, 2009-07-23: Apparently it helps to be awake while doing this. The solution to the problem above is rather simple. svnadmin does not work on a checkout, but only on the real repository. So in case you are hosting with an external provider such as Unfuddle, Hosted Projects, CVSDude, Assembla and so on, you won't be able to svnadmin dump on a working copy.

svnadmin & svnsync

Since the current provider charges extra for a backup and the apparently figured out we are trying to save ourselves, I stfw (again) and came up with these instructions (source) on how to create a local copy of the repository. They assume your username is svnsync, so in case that's not it, you'll need to adjust it.

  • svnadmin create repo-local
  • copy the following script in repo-local/hooks/pre-revprop-change:

    #!/bin/sh USER="$3"

    if [ "$USER" = "svnsync" ]; then exit 0; fi

    echo "Only the svnsync user can change revprops" >&2 exit 1

  • Run the following command to initialize the sync:

    svnsync init --username svnsync file://`pwd`/repo-local

  • Run this to create the local copy:

    svnsync sync file://`pwd`/repo-local

Local copy, ftw! Now, proceed on to svnadmin dump ./complete/path/to/repo-local > repo.dmp.

rsvndump [still] to the rescue

Updated, 2009-07-29: Regardless of the above, rsvndump is still the easiest way to backup a remote repository.

rsvndump is pretty nifty, you can get it from the SourceForge page, but it's also available in FreeBSD's ports (Woohoo!), and it works like a charm:

server# rsvndump -u user -p password > dump
* Dumped revision 0.
* Dumped revision 1.
* Dumped revision 2.
* Dumped revision 3.
* Dumped revision 4.

I know, I know. Not a super-duper post on the usual topics but I thought I'd share it anyway. I'm very much hoping that Google picks it up to save someone else' sanity.

| More