We run a subversion service for a number of different research groups. Generally we create a separate subversion repository for each group. Obviously looking after this data is important. It’s not a good idea to lose months of someone’s work.
Fortunately backing up a subversion repository is pretty simple. Subversion ships with a utility called svnadmin. One of the functions of which is to dump a repository to a file.
As the repository owner do:
svnadmin dump /path/to/repository > subversion_dump_file
I have a directory full of subversion repositories so what I really want is a script that will find all the subversion repositories in the directory and dump them with sensible filenames. With my usual lack of imagination I’ve called this script svn_backup. It runs svnadmin verify against each file in the directory it’s given. If any of them turn out to be subversion repositories it dumps them using svnadmin dump.
$ ./svn_backup svn_backup -s subversion_dir [-b backup_dir] [ -o logfile] script to backup subversion repositories -s directory containging subversion repositories -b directory to dump backups to. defaults to /tmp -o file to output names of backups to
So I now have an entry in cron.daily like:
svn_backup -s /var/www/subversion -o /tmp/svn.log -b /var/backups/svn
The reason I write the backups to a log file is that it allows me to run a script once a week that copies the latest backups to Amazon’s S3 storage system.