Backup Multiple SVN Repositories

There are a number of different ways to backup your svn data (svnadmin hotcopy, sync, etc).  I am currently using the hot-backup.py script supplied with svn.  I added a script to backup all the repositories in my repo directory as hot-backup.py only does one repository.  Then I put the script into cron and away we go.  Note that if you want to modify the number of backups edit the hot-backup.py script and change the num_backups variable value.  Here is the script:

#! /bin/bash
REPO_DIR="/srv/svn/repositories"
BACKUP_DIR="/srv/backup/svn/repositories"
BACKUP_CMD="/usr/share/subversion/tools/backup/hot-backup.py"

for repo in $REPO_DIR/*
do
reponame=`basename $repo`
if [ ! -d $BACKUP_DIR/$reponame ]; then
mkdir -p $BACKUP_DIR/$reponame
fi
$BACKUP_CMD $REPOS_DIR/$reponame $BACKUP_DIR/$reponame/
done

Leave a Reply