Subversion Notes for Ubuntu

Installation

Use apt-get to install subversion

# apt-get install apache2
# apt-get install subversion
# apt-get install libapache2-svn

There's some more stuff here.

Creating Repositories

Let's say I have a new project named "Differ" (for which I want to create a new repository)

On the server machine run this command:

# svnadmin create /home/svn/Differ

Modify permissions of repository:

# chown -R www-data:www-data /home/svn/Differ

I then went and modified /etc/apache2/mods-available/dav_svn.conf

<Location /Differ>
  DAV svn
  SVNPath /home/svn/Differ
</Location>

Restarted Apache:

# /etc/init.d/apache2 restart

On the client machine

$ svn checkout http://ghen/Differ

I now copied over the files from my saved Differ folder where I had originally written my program and then did an svn add, and an svn commit. Ok. I'm sorta lying: I used TortoiseSVN.

Properties

To see the file properties:

$ svn proplist --verbose *

This seems to die on the first non version controlled file.

To set the properties:

$ svn propset svn:mime-type image/ico *.ico

Repository Backup

I am doing a manually initiated repository backup as proscribed in the Subversion manual. The amount of data that I deal with is not that large so I always do a full backup of all of my repositories. I have a Perl script that enumerates all of my repositories and uses hot-backup.py to do the actual backup. hot-backup.py appends the revision number to the end of the folder so my Perl script removes this so that I can just copy all of my backup folders back to restore.

I then use rsync to remotely backup these directories to another machine.

Repository Restore

Restoration was trivial. Once subversion was reinstalled I copied my backed up subversion folders to the correct svnroot which was /usr/local/src/svnroot and modified the permissions as follows:

# chown -R apache /usr/local/src/svnroot
# chgrp -R apache /usr/local/src/svnroot

I then had problems with permissions, but allowing everyone access to my svnroot solved this problem. I don't like this solution, but for the moment it is ok.

# chmod -R ugo+rw /usr/local/src/svnroot

I then had to reconfigure the /etc/httpd/conf.d/subversion.conf file so that Apache was aware of all of my repositories. I found it faster to write a little Perl program to do this. Here it is:

#!/usr/bin/perl -w

use strict;

my $svnroot = '/usr/local/src/svnroot';
opendir (DIR, $svnroot) or die "Cannot open $svnroot\n";
my @files = readdir(DIR);
closedir(DIR);

foreach my $file (@files) {

        next if $file eq '.';
        next if $file eq '..';

        next if not -d "$svnroot/$file";
        printconf( $file );
}


sub printconf
{
        my $dir = shift;

        print "\n\n";
        print "<Location /$dir>\n";
        print "  DAV svn\n";
        print "  SVNPath $svnroot/$dir\n";
        print "</Location>\n";
}

After saving this to a file I then ran it like this:

# makesvnconf >> /etc/httpd/conf.d/subversion.conf

Then restarted apache:

# apachectl restart

And voila, everything's restored!

Links