How do I backup my TRAC installations?

We use separate TRAC instances as our ticket system for many projects and need to have them moved off site several times a day for disaster recovery.

What is the best way to make this happen? Is there something similar to svnsync for subversion?


To fully recover trac environment you need following things:

  • backup DB;
  • backup configuration files;
  • backup wiki files (html and attachments);
  • backup password files if you're using htpasswd auth;
  • optional plugins (even though this are available for download, I'd backup them for quicker recovery);

In case of the standard setup (with SQLite as BD backend), this means that all you have to backup are the contents of the trac install dir.

Also it would be useful to create list of all Python packages you need to install with easy_install.


I've used a script to safely backup both SVN + the full Trac instance into a .tar.gz file. From there, it can be backed up as usual with the other files..

#!/bin/sh

DATE=`date +%F-%H%M%S`
nice svnadmin dump /var/svn/trac.example.com > dump.$DATE.svn
nice trac-admin trac.example.com hotcopy trac.example.com-$DATE.trac

# take the SVN dump, and trac hotcopy, put into a dated TGZ anc copy to /backup...    
nice tar czf svn-trac.$DATE.tar.gz  backupTrac.sh startTracd.sh trac.htdigest \
           trac.example.com-$DATE.trac dump.$DATE.svn && \
   cp svn-trac.$DATE.tar.gz /backup/trac/ &&
   rm -rf trac.example.com-$DATE.trac dump.$DATE.svn

You might want to take a look at TracBackup:

Since Trac uses a database backend, some extra care is required to safely create a backup of a project environment. Luckily, trac-admin has a command to make backups easier: hotcopy.

Note: Trac uses the hotcopy nomenclature to match that of Subversion, to make it easier to remember when managing both Trac and Subversion servers.