Easy subversion backups

Anyone using a subversion server heavily needs good backups of their code. svnadmin dump is a good way to make regular backups. Or the mirroring method may work well for you.

I found a really useful, simple, elegant and clean tool to backup SVN repos with: svnbackup by Doug Hellmann (don't let the name fool you!). His script utilizes the existing tools but adds value, which is excellent in my book. He dumps the svn repo using svnadmin, splits the repo into commits sets (100 by default) and compress them in the process. The greatest feature, IMHO, is however the ability to let the scripts scp the backups to a different server! Genius! Works likes a charm in 30 seconds!

Here is my daily cron job:

#!/bin/bash
# http://code.google.com/p/svnautobackup/
# create dump of main SVN repo(s)
/usr/local/bin/svnbackup.sh --scp userid@server:/data/users/userid /var/svn/repositories/svnrepo/
echo "***SVN io_se dumped" >> /var/log/messages


If you have more than one repo, build in a for-loop to cycle all the repos. Brilliant! The wiki also has a restore command for your convenience.

No comments: