Wednesday, October 15, 2008

Migrating subversion repository

I have a small subversion repository on my old server. I want to migrate it to the fit-PC.

Looking at the relevant section of Version Control with Subversion, it looks like it should be easy. Just create a dumpfile on the old box and load it to a new repository on the new one.

So on the old box
$ svnadmin dump repos > dumpfile
and copy the dumpfile onto the new box.

Last time I setup subversion + apache for HTTP access. This time I'm going to try svn+ssh.

As usual, Ubuntu provides a good general reference.

Install subversion
$ sudo apt-get install subversion 
Setup a subversion user and group, add myself to the group
$ sudo addgroup svn
$ sudo useradd -g svn -m -p <pwd> svn
$ sudo usermod -a -G svn <my_user>
Create the repository and load the dumpfile
$ sudo su svn
$ cd /home/svn
$ svnadmin create repos
$ svnadmin load repos < dumpfile
I want svnserve process to start when the box boots, so I added this line to /etc/rc.local:
sudo -u svn svnserve -d -r /home/svn
I'll make a proper init.d script like this one later.

Restart the box

Verify I am a member of the svn group
$ groups
Verify that svnserve process started
$ ps -ef | grep svnserve
Verify I can read the repository locally
$ svn list svn://localhost/repos/<project>/trunk

Setup access to the repository from Eclipse on my laptop

(I already have the subclipse plugin installed).

File / Import
Checkout Projects from SVN
Create a new repository location

That fails with an error dialog and this message on the console:
    The system cannot find the file specified. 
svn: Can't create tunnel: The system cannot find the file specified.

Back to Google... The answer is here.

The problem was that Eclipse was not configured with an SSH client. Quick fix for me was to switch the Eclipse / Team / SVN configuration from JavaHL (which requires external SSH client) to SVNKit (which includes one). Now it works.

Edit! Actually, not quite there yet...

On attempting to commit to the repository, I got error
svn: Commit failed (details follow):
svn: Can't create directory '/home/svn/repos/db/transactions/1-1.txn':
Permission denied
It turns out that svn+ssh does not connect to the svnserve daemon I started above, but rather creates a temporary svnserve process (on each invocation) as the ssh user. And in the setup above, the ssh user has read access to the repos, but not write access. (Just like if you use subversion + apache and don't make the repository writable by the www-data user).

Temporary workaround (to commit my current work) is to make the whole repository writable by my ssh user
$ cd /home/svn
$ sudo chown <sshuser>:<sshuser> -R repos
Now the commit succeeds.

Next task is to read the relevant section of the Subversion manual more carefully. My original setup above will support working with the repository using svn://<host>/repos. I might just go with that for now.

1 comment:

  1. It's worth noting that svn+ssh doesn't actually require svnserve at all. It's basically equivalent to file:// over ssh.
    Or at least, such is my understanding.