Monday, November 5, 2012

How to migrate into Subversion 1.7

So, most of Linux distribution has not included Subversion 1.7 yet. What I like most from Subversion 1.7 is that it only contains one .svn directory just like Git (I'm a Git fan actually). I'm going to document my experience installing Subversion 1.7 on Ubuntu 11.04 and migrating from 1.5 into this version

Adding to repo

  1. Check if version 1.7 is available to download
    apt-cache show subversion | grep Version:
  2. If it is not, add to repository
    echo "deb lucid svn17" | sudo tee /etc/apt/sources.list.d/svn.list
    sudo wget -q -O- | sudo apt-key add -
    sudo apt-get update
    sudo apt-get dist-upgrade


  1. Install the package
    sudo apt-get install subversion
  2. Create repository directory
    sudo mkdir /var/lib/svn

Access via HTTP

  1. Install required packages
    sudo apt-get install libapache2-svn
  2. Create file /etc/apache2/mods-available/dav_svn.conf containing
    # Allowing to list all repositories available
    DAV svn
    SVNParentPath /var/lib/svn
    # Authentication
    AuthType Basic
    AuthName "Subversion Repository"
    AuthUserFile /etc/apache2/dav_svn.passwd
    # Any access (GET, POST, etc) requires authenticated users
    Require valid-user
    # Disable request size limit
    # LimitXMLRequestBody 0
  3. Create empty file for authentication
    sudo touch /etc/apache2/dav_svn.passwd
  4. Restart Apache
    sudo service apache2 restart
  5. Create a repo and user for testing (see the following guidence)

Create a repository

Do the following commands using root by invoking "sudo su -"
cd /var/lib/svn
svnadmin create myproject
chown -R www-data.www-data myproject

Create user

Only if you use AuthUserFile directive like defined above.
  1. Create user
    sudo htpasswd -c /etc/apache2/dav_svn.passwd user_name
  2. Restart Apache
    sudo service apache2 restart
  3. Test checkout
    svn co http://hostname/svn/myproject myproject --username user_name

Using LDAP auth

  1. Activate LDAP authentication module on Apache 2
    sudo a2enmod authnz_ldap
  2. Change configuration to use LDAP On /etc/apache2/mods-available/dav_svn.conf, comment AuthUserFile and put the following lines
    AuthBasicProvider ldap
    AuthLDAPURL ldap://myldapserver/dc=mybcmp,dc=com?uid?sub
    AuthLDAPBindDN cn=admin,dc=mybcmp,dc=com
    AuthLDAPBindPassword "myLdapAdminpassword"
  3. Reload configuration
    sudo apache2ctl restart

Migrating from older SVN

  1. Copy repositories' directory of older SVN into the new SVN directory.
  2. Change permission recursively into www-data.
  3. I suggest you use svndump instead of this way.

Linux way to use svndump faster

  1. Mount remote directory.
    sshfs /tmp/remoteparent
  2. Dump and restore Run the following script as root (put it in an executable file e.g.
    cd /tmp/remoteparent/
    IFS=$(echo -en "\n\b")
    for repo in *; do
      svnadmin create "$t"
      svnadmin dump "$repo" | svnadmin load "$t"

After some research, I came into some conclusions:
  • User is stored in each SVN repository metadata.
  • SVN Server 1.7 can serve old repo directory (the repo structure was created by older version of SVN). Client 1.7 will see only one .svn directory.
  • Migration using copy way compared to svndump way, both take the same time in doing "svn log". But the size on the server is quite different. Copying is larger than svndump (46M vs 39M on one example of mine)


No comments: