Backing up Subversion Repositories using hot-backup.py

Posted by Ben Reubenstein Tue, 24 Apr 2007 13:12:00 GMT

Subversion is an excellent tool for versioning your code and projects. Backing up this data is crucial in case of a catastrophic failure. Subversion has several ways to create backups, this tutorial will focus on using hot-backup.py to accomplish the task. For more information on the various methods for backing up subversion consult the documentation.

This tutorial assumes you have an existing repository and focuses on a *nix environment interacting with the shell as root.

1. Get the latest version of the script.

# wget http://svn.collab.net/repos/svn/trunk/tools/backup/hot-backup.py.in

2. On my system (gentoo) I moved the script into /usr/sbin so that the file is in my path.

# mv ~/hot-backup.py.in /usr/sbin/hot-backup.py

3. Open the file in your favorite text editor adjusting the paths to svnadmin and svnlook. Be sure to give the full path or the script will fail even if those executables are in your path (at least it did for me).

# vi /usr/sbin/hot-backup.py
# Path to svnlook utility
svnlook = "/your/path/to/svnlook"

# Path to svnadmin utility
svnadmin = "/your/path/to/svnadmin"

4. In order to automate the task, we'll create a simple cron script to call the hot-backup.py for each one of our repositories. In order to save disk space, we'll pass the script an option to compress the files. Valid archive types include gz, bz2, and zip. Be sure that the directory you are backing up to exists, or the script will fail.

# vi /etc/cron.daily/backup_subversion
# backup_subversion v.1
hot-backup.py --archive-type=gz /my/repository1 /my/backup/location1
# if you have more than 1 repository, simply
# add a new line for each one
#
# hot-backup.py --archive-type=gz /my/repository2 /my/backup/location2
# chmod +x /etc/cron.daily/backup_subversion


5. Test the script.

# /etc/cron.daily/backup_subversion
Beginning hot backup of '/my/repository1'.
Youngest revision is XX
Backing up repository to '/my/backup/location1/repository1-XX'...
Done.
Archiving backup to '/my/backup/location1/repository1-XX.tar.gz'...
Archive created, removing backup '/my/backup/location1/repository1-XX'...

That's it. Feel free to post questions or corrections in the comments.

Posted in  | Tags , ,  | 2 comments

New Tutorial: Using Crontab

Posted by Ben Reubenstein Sat, 06 May 2006 11:36:00 GMT

For a while now I have been doing a lot of regular tasks manually on my OS X box. On my linux boxes I have been using good old Cron for these tasks. Today I started using crontab, since it is installed by default on Mac OS X. There are several tutorials and sites that have information on crontab, but they were not as direct as I would have liked so I put together this tutorial, Using Crontab with Mac OS X, Unix, and Linux. Enjoy!

Posted in , ,  | 2 comments

Google Maps Snippet

Posted by Ben Reubenstein Wed, 15 Feb 2006 11:52:00 GMT


Lately I have been working with the Google Maps API. I put together an example of adding and removing a marker from a Google map.

Read about it here

Posted in , ,  | no comments

Lighttpd and AWStats

Posted by Ben Reubenstein Mon, 23 Jan 2006 14:38:00 GMT

Want to use AWStats but don't run Apache? Here is a tutorial I wrote on getting AWStats and Lighttpd to work together. If you don't know what I am talking about, AWStats is a log analyzing package. It is a very useful tool to get some good metrics on website traffic. When I moved to Rails I also moved to Lighttpd as a webserver. Luckily AWStats came along for the ride.


Tutorial: Lighttpd + AWStats

Posted in , ,  | 1 comment