Automatically backing up multiple Subversion repositories

We’re using Subversion to manage files for all of our projects in the Teaching & Learning Centre. More projects means more Subversion repositories to backup. Instead of maintaining a list of projects and repositories, we stick all repositories in a common root directory, and I’ve just put together a dead simple script to automatically dump all of them to a directory of my choosing. I’ve added this script to the crontab for the www user on the server, and it runs svndump on all repositories, gzipping the output for archive (and possibly restore).

The output is stored in a specified backup directory, which is then picked up via rsync from my desktop Mac, and copied to the external backup drive.

#!/bin/sh

SVN_REPOSITORIES_ROOT_DIR="/svn_repositories/"
BACKUP_DIRECTORY="/Users/Shared/backup/svn/"

for REPOSITORY in `ls -1 $SVN_REPOSITORIES_ROOT_DIR`
do
echo 'dumping repository: ' $REPOSITORY
/usr/local/bin/svnadmin dump $SVN_REPOSITORIES_ROOT_DIR$REPOSITORY | gzip > $BACKUP_DIRECTORY$REPOSITORY'.gz'
done

We’re using Subversion to manage files for all of our projects in the Teaching & Learning Centre. More projects means more Subversion repositories to backup. Instead of maintaining a list of projects and repositories, we stick all repositories in a common root directory, and I’ve just put together a dead simple script to automatically dump all of them to a directory of my choosing. I’ve added this script to the crontab for the www user on the server, and it runs svndump on all repositories, gzipping the output for archive (and possibly restore).

The output is stored in a specified backup directory, which is then picked up via rsync from my desktop Mac, and copied to the external backup drive.

#!/bin/sh

SVN_REPOSITORIES_ROOT_DIR="/svn_repositories/"
BACKUP_DIRECTORY="/Users/Shared/backup/svn/"

for REPOSITORY in `ls -1 $SVN_REPOSITORIES_ROOT_DIR`
do
echo 'dumping repository: ' $REPOSITORY
/usr/local/bin/svnadmin dump $SVN_REPOSITORIES_ROOT_DIR$REPOSITORY | gzip > $BACKUP_DIRECTORY$REPOSITORY'.gz'
done

9 thoughts on “Automatically backing up multiple Subversion repositories”

  1. Jeff – we’re already using Mantis and Maven on projects, with WebSVN on some. TRAC looks cool, but I don’t really want to throw Yet Another Piece Of Software into the mix at the moment…

  2. Bill – I’ve seen no issues here, connecting from my 10.4.x desktop to my 2 10.3.x servers, nor while connecting to my 10.4.x powerbook. At least everything appears to be working – files get copied as expected. Now you’ve got me worried a bit. The pages you listed mention errors and failures, which don’t appear to be affecting me.

  3. Darcy, to ease your worry, I believe the problem appears when using the ‘-E’ flag to copy the metadata. If you are backing up flat file data then you can avoid this.

  4. Hi,
    We have a SVN Server installed on OpenSuse. We will have multiple repositories on this server.
    Will you please mail me the steps for taking backup of my SVN Repositories? Can we schedule backup of SVN repositories? If, then please send me the steps for that also.
    I am planning to schedule the backup of my SVN Repository and i will try to restore it on dummy SVN Server. As it will be work as a production server we need to set the backup and restore policy for the same. I am new in linux so if you can help me out to explain it in step by step it would be really helpful for me 🙂

    Thanks in Advance

    Regards,
    Mahesh

Comments are closed.