Repairing broken Subversion repository

Somehow Subversion repository based on BDB tends to break at least in our case working on Fedora Core 3 with Trac 0.8.1 Usually an indication of this is either your Subversion client (TortoiseSVN, svn, etc) stops responding for no reason or you cannot browse any sources using Trac “Browse” link.

Here are the steps one need to take in order to fix this problem:

  1. log in to your Subversion server, be sure you have appropriate (possibly root) privileges

  2. stop Apache:

    /sbin/service httpd stop
    
  3. check whether it actually stopped:

    ps axu | grep http
    
  4. if you see something like this:

    apache    5420  0.0  2.0 17320 4556 ?        S    13:25   0:00 /usr/sbin/httpd
    apache    5423  0.0  2.0 17320 4564 ?        S    13:25   0:00 /usr/sbin/httpd
    
    be sure to kill the remaining processes:
    kill -9 5420 5423
    
  5. fix the repository with svnadmin recover command:

    svnadmin recover /var/www/svn/cp
    
  6. change repository owner/group back to apache:

    chown -R apache:apache /var/www/svn/cp
    
  7. start Apache:

    /sbin/service httpd start
    

Everything should work fine now.