Sam-I-Am on Web Development

Sam Foster on the web and web-ish software developmen

Friday, February 22, 2008

Restoring SVN repositories from disk - a story

I recently had to move off a company laptop I'd been using for a while, and (thanks to the flu) didnt have much time to do it. So, I backed up those directories I knew had any personal projects and data in and crossed-fingers I'd be able to get what I needed out of there when the time came.

One of the directories I got housed my subversion respositories (I'd been using the flat-file db option). When I started setting back up on a new laptop (and new-to-me platform in OSX) I was faced with a little problem: How to let the new install of subversion know about the old data.

A little reading around in the SVN book soon told me that what you are /supposed/ to do is run a svnadmin dump command, then create the new repos and

    svnadmin load /path/to/reponame < /path/to/my/repo1.dump

Nice to know - for next time. After some searching and asking around, I finally got a pointer (from the evolt list)

   svnserve --daemon --root "C:\Path\to\Subversion Repository"
That wouldnt work as-is, but it pointed me in the right direction. Subversion of course has a notion of a root directory where it expects to find everything. I was running subversion via apache though. I'd gone through the basic set up to configure it, and it was busily serving up an entirely fresh and empty repo. To cut a long story short, I finally ended up with this:

LoadModule dav_svn_module /usr/libexec/apache2/mod_dav_svn.so
<Location /svn>
     DAV svn
     SVNParentPath /my/laptop/backup/SVN
     AuthType Basic
     AuthName "Subversion repository"
     AuthUserFile /etc/apache2/svn-auth-file
     Require valid-user
</Location>

SVNParentPath was the magical incantation I needed. After that I was left only permissions to fix. That's apparently where most people stumble. And its not my strong point. I can chmod 755 myscript.cgi like the rest of them, but dont ask me to explain what it (and all its possible variations) does exactly. I dug briefly into a nice tutorial on chmod, to grok the details once and for all, but found this walkthrough, and this one which instead supplied all the information I needed.

On OSX/Leopard I needed to use the www user, otherwise that was basically it. sudo acpachectl restart picks up the new apache config. http://localhost/svn/my-repo shows a directory listing of the repo, and:

svn co --username me http://localhost/svn/clients-repo \
/path/to/clients

...finally got me pay dirt - the full directory tree, with version history

0 Comments:

<< Home