Trac Backup

Trac uses an internal database to store its data, meaning some extra care needs to be taken when backing up a trac project. This means that we can’t just copy/tar/gz/etc the folder and we need to make sure the database is properly closed and no one is writing to it at that particular time. Of course this is useful for big installation, while for a small trac usage install, you can probably just tar gz the trac folder and be just fine. But even in that case, I would choose the safe method and do it right because it is so easy: the trac-admin command provides the hotcopy switch just for this.

Basically all you have to do is:

trac-admin <trac_project_path> hotcopy <backup_path>

and of course if you are familiar with svn you will notice that it is similar to the way you use svnadmin hotcopy

For example if my trac installation is under /var/trac/project and I want the backup inside /mnt/backups/trac/ I will use:

trac-admin /var/trac/project hotcopy /mnt/backups/trac/

You would normally wrap this command inside a simple backup script and run it from cron based on your needs, or you can use one existing script like trac-backup; this can be useful if you have several trac projects in the same directory and want to backup them daily, as trac-backup will handle that nicely.

comments powered by Disqus