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

See Also

comments powered by Disqus