13 November 2007

trac: backups, Gantt plugin, concluding remarks

This is the third installment of a series on trac, Web-based pr0ject management software. The previous segments talked about installing and using trac.

trac comes with a command-line utility called trac-admin, which can (among other things) perform backups of individual trac projects. The following is a shell script you could put in /etc/cron.daily to back up all your trac projects each night:

#!/bin/bash

TRAC_ROOT=/var/www/trac/tracroot
TRAC_BAC_ROOT=/var/trac_bac

TODAY=$( date +%Y%m%d%H%M%S )
mkdir -p $TRAC_BAC_ROOT/$TODAY
for i in $TRAC_ROOT/*
do
DEST=$TRAC_BAC_ROOT/$TODAY/$( basename $i )
DEST_TARGZ=${DEST}.tar.gz
/usr/bin/trac-admin $i hotcopy $DEST
tar czf $DEST_TARGZ $DEST
rm -rf $DEST
done


This uses the trac-admin hotcopy feature to make a compressed archive of each individual project (putting them in time/date-labeled directories in /var/trac_bac).

This series discussed the WebAdmin plugin. I also tried the TracGantt plugin, which makes Gantt charts of your project. I found that I didn't much care for this plugin. You have to enter an extra four data fields for each ticket, one of which is a list of ticket dependencies (e.g., completion of this ticket is dependent on completion of that ticket). The Gantt charts don't clearly display these ticket dependencies, so it seems like a wasted effort. And for a large project, the chart becomes too big for useful printouts, and the plugin doesn't offer exports in other formats. So TracGantt didn't really do it for me. shrug

In closing, I really like trac, and it's been very helpful to me in my work. Clearly, trac is designed to manage software development projects. But with a little imagination, I think it could be used quite effectively to manage just about any kind of project, even something as simple as a running 'to-do' list.

4 comments:

Anonymous said...

Thanks for the backup script. For our installation of 0.10.4 I had to remove the mkdir. The admin tool refused to copy to an existing directory. Other than that it works perfectly. Thanks again.

mbrisby said...

Glad it was helpful.

Marius said...

Nice script. I had to do some small changes before I could use it, and you might want to include them in your code.

1. if you have files (as we do in the trac folder) trac-admin will give errors when trying to hotcopy them (just create a file in your trac folder and see it). This tries to find only the folders in the current trac path.
2. i don't like to have in the tar archives full paths, hence the cd prior to the archive.

Cheers,
- Marius -

--- trac-backup.orig 2009-02-27 14:50:40.000000000 +0000
+++ trac-backup 2009-02-27 15:35:21.000000000 +0000
@@ -38,12 +38,13 @@
mkdir -p $TRAC_BAC_ROOT/$TODAY
fi

-for i in $TRAC_ROOT/*
+for i in $(find $TRAC_ROOT/* -maxdepth 0 -type d)
do
DEST=$TRAC_BAC_ROOT/$TODAY/$( basename $i )
DEST_TARGZ=${DEST}.tar.gz
trac-admin $i hotcopy $DEST
- tar czf $DEST_TARGZ $DEST
+ cd $TRAC_BAC_ROOT/$TODAY
+ tar -P -czf $DEST_TARGZ $( basename $i )
rm -rf $DEST
done

mbrisby said...

Thanks, Marius. I put this in google code at some point (http://mbrisby.blogspot.com/2008/01/google-code-trac-backup.html), and I'll probably add your changes (when I get a little time).