Backing Up Trac Environments

The Problem

trac-admin is Trac's administrative tool. Through trac-admin, an admin may backup individual projects. However, trac-admin does not provide a mechanism to backup the Trac root directory and therefore all projects under this directory. Secondly trac-admin does not provide a mechanism for compression of said backups. In search for an solution to these two issues, I came across trac-backup.

trac-backup backups the entire Trac root directory and compresses the individual project directories through tar and gzip. I modified trac-backup to provide more verbose logging messages, compresses the entire backup of the Trac root directory and only keeps the ten newest backups.


Install Trac-Backup-NG

trac-backup-ng relies on the delbut script. delbut deletes all but the newest number of files specified by the first argument supplied to it. John Simpson wrote delbut and as such you will need his GPG key to verify delbut's signature. The download listed below for delbut is valid for the file as of May 20, 2008. Please check John's code page for the latest download block.

# cd /usr/local/bin
# wget -c http://www.jms1.net/code/delbut
# chmod 755 delbut
# chown root.root delbut

Next, you need to download trac-backup and install it on your server. The below commands will install trac-backup.

# cd /usr/local/bin
# wget -c http://www.antagonism.org/scripts/trac-backup-ng
# chmod 755 trac-backup-ng
# chown root.root trac-backup-ng

trac-backup-ng takes two arguments. The first argument is the Trac environment's root directory. This is the same directory as set by the "TracEnvParentDir" directive in your httpd.conf file. The second argument is the directory where you want to store the backups. The below example demonstrates trac-backup-ng making a hotcopy of the trac environment root directory, "/var/www/html/trac" and its projects to the backup directory, "/backup".

# trac-backup-ng /var/www/html/trac /backup

By default, trac-backup-ng will keep the last ten backups. You may modify this by editing the script and changing the number proceeding the call to delbut.


Downloads

File: delbut
Size: 2,184 bytes
MD5: a761945725f32869a3fb856dfabeff6c
SHA-1: 0131b3d9f048dee27c4ac2e834811366f816051e
RIPEMD-160: 2000ab1f1fb43300ce2235557c12e1dcf1821d0e
PGP Signature: delbut.asc
File: trac-backup-ng
Size: 2,508 bytes
Date: 2008-05-20 09:37:28 -0700
MD5: 58bacca296566a3d40b07fe266658d1a
SHA-1: e3087711f34fd59b9b7f64c612bb07b640995ac0
RIPEMD-160: 79551b6a65d519f396ddde4304c5efdfffe50f24
PGP Signature: trac-backup-ng.asc