Silmor . de
Site Links:
Impressum / Publisher

Subversive Activities

Installing Subversion

Subversion (web link) is the official successor of the CVS version control system. It overcomes most of the shortcomings of CVS.

Like CVS it can be used in a stand alone local mode and via several network protocols.

This article is only intended to give you an overview of how Subversion works and how much is needed for a typical installation. It is not intended on replacing the actual Subversion manual - which is a quite good read anyway.


Subversion knows about transactions, that means a change is either committed completely or not at all. It versions the whole repository as a tree of files and directories, so each version is a snapshot of the whole repository tree.

It keeps track of file history during normal updates as well as during copy and move actions. Like CVS it uses the copy-modify-merge approach instead of locking.

Subversion views branches and tags as copies of the initial directory.

Local Subversion

Using subversion locally is as easy as using CVS. One simple creates a repository and uses the Subversion command line client (or the integrated modules of various IDEs) to work with the repository. Below is an example how one can create a repository, import some sources, update them, etc.:

#create the repository and create initial directories:
svnadmin create /home/konrad/mysvn
svn mkdir file:///home/konrad/mysvn/myproject/trunk
svn mkdir file:///home/konrad/mysvn/myproject/branches
svn mkdir file:///home/konrad/mysvn/myproject/tags

#initial checkin of some sources
cd ~/mysrc
svn import . file:///home/konrad/mysvn/myproject/trunk

#checkout the sources
cd ~
svn checkout file:///home/konrad/mysvn/myproject/trunk mysrc2

#modify and register for checkin:
cd mysrc2
echo hallo >newfile.txt
svn add newfile.txt
svn move oldfile.txt oldfile2.txt

#check the status of the files:
svn status

svn commit -m "added one, moved another"

If more than one user accesses the repository care must be taken about the file system access rights, all users need read and write access.

Subversion in the Net

Subversion can be run via its own protocol (svnserve) or WebDAV - a variant of HTTP. Both protocols can be tunnelled through a cryptographic protocol, which is SSH for svnserve and HTTPS for WebDAV.

Again, the administrator needs to care about access rights for the Subversion repository. For WebDAV this is the user the web server runs under and for standalone svnserve this is the user it is started as. For an SSH-tunnelled svnserve this is all users that can access the repository.

Most installations will use WebDAV. Normally secured with SSL.

Subversion among Apaches

After installing Apache 2.0, installing Subversion is pretty easy:

  1. install Subversion and the Subversion Apache module
  2. create the initial repository (or multiple repositories, see below)
  3. link the mod_dav-svn module config into Apaches mods-enabled directory
  4. create the configuration for Apache/SVN

I decided to create multiple repositories (one for each group of projects I persue) and to create them all in the directory /svn. You can see above how a repository is created, you only need to chown it to www-data, so that Apache can write on it. I store the ACL-configuration and the user account data in /svn/admin.

You can add/modify accounts with a simple command:

htpasswd -m /svn/admin/passwd myuser

When you execute this command the first time you should use -cm instead of -m to create the file first. The ACL file looks similiarly easy:

somegroup = myuser
dreams = myuser anotherone

konrad = rw

@dreams = rw

@somegroup = rw

* = r

The [groups] section defines all user groups that are known to the system. The [x:/path] sections define the access rights in repository x path /path and subdirectories. The [/] section describes the / path in all repositories. All entries are of the form "user = right", "@group = right", or "* = right" for anonymous and/or everybody. The rights can be r (read only), rw (read/write) and an empty string (no rights or revoke all rights).

For Apache to actually expose the repositories and use the configuration above you need to add this to the VirtualHost, which should serve the Subversion Clients (normally the one serving HTTPS):

<Location /svn>
        #activate SVN:
        DAV svn
        SVNParentPath /svn

        #Access Control List:
        AuthzSVNAccessFile /svn/admin/access

        #try anon access first, then authenticated
        Satisfy Any
        Require valid-user

        #auth method:
        AuthType Basic
        AuthName "Subversion Repository On Silmor"
        AuthUserFile /svn/admin/passwd

Most of these statements refer to the ACL configuration above.

This is probably the typical configuration one would want for an open source project, but many others are possible. (See the subversion manual for details.)

Having a look

So far we have a working Subversion server. But it would be nice to have a tool to view repositories and versions online. With Debian you only need to install websvn and add this line to the VirtualHost:

Include /etc/websvn/apache.conf

A "dpkg-reconfigure websvn" will let you chose the repositories to display, or you modify the websvn config by hand.


There are several methods to do a backup of a Subversion repository. The easiest is to do a dump. This script dumps and packs all repositories in /svn:


svns="`(cd /svn; ls |grep -v admin ) `"

for i in $svns ; do
 ( set -e
        rm -f svn-$i.dump.bz2.bak
        test -f svn-$i.dump.bz2 && mv -f svn-$i.dump.bz2 svn-$i.dump.bz2.bak
        ( cd /svn ; su www-data -c svnadmin dump $i ) 2>svn-$i.log | bzip2 >svn-$i.dump.bz2
        rm -f svn-$i.dump.bz2.bak
 ) 2>&1

Webmaster: webmaster AT silmor DOT de