http://trac.edgewall.org/ : Wiki & Bugtracking
Due to some circumstances on our Debian server with multiple (versions of) Trac installations I had to adapt it a bit, but the basis is Trac-backup as found on Google Code.
I call the first script from Bacula.
#!/bin/sh # slightly adapted version to the one supplied on the wiki # it makes use of an altered trac-admin /usr/bin/trac-adminconsole # trac-adminconsole is an adapted version of trac-admin from Trac Debian package 0.10.3-1etch3 # to accomodate for the usage of the manually installed /usr/local/src/Trac-0.11rc1 # adjustment: trac.scripts.admin to trac.admin.console /etc/bacula/extra-scripts2/trac-backup /home/system/trac /home/storage/backupdump/trac
This script executes the next one with the correct parameters.
I adapted that script to use an adjusted version of the trac-admin script as that needed some editing to work with the correct version of Trac on our server. So you probably want to stick to the default “trac-admin”
#!/bin/bash # OZ: #export PYTHONPATH=/usr/lib/python2.4:/usr/lib/python2.4/site-packages TRACADMIN=/usr/bin/trac-adminconsole function show_usage() { printf "usage: %s [ -d ] tracroot_dir destination_dir\n" \ $( basename $0 ) >&2 echo "(try the -d option if trac-admin complains about mkdir)" } CREATE_DESTINATION=1 while getopts 'd' OPTION do case $OPTION in d) CREATE_DESTINATION=0;; ?) show_usage exit 1 ;; esac done shift $((OPTIND - 1)) TRAC_ROOT=$1 if [ -z $TRAC_ROOT ]; then show_usage exit 2 fi if [ ! -d $TRAC_ROOT ]; then echo "directory '$TRAC_ROOT' does not exist" exit 4 fi TRAC_BAC_ROOT=$2 if [ -z $TRAC_BAC_ROOT ]; then show_usage exit 2 fi TODAY=$( date +%Y%m%d%H%M%S ) if [ $CREATE_DESTINATION -eq 1 ]; then mkdir -p $TRAC_BAC_ROOT/$TODAY fi for i in $TRAC_ROOT/* do DEST=$TRAC_BAC_ROOT/$TODAY/$( basename $i ) DEST_TARGZ=${DEST}.tar.gz $TRACADMIN $i hotcopy $DEST tar czf $DEST_TARGZ $DEST rm -rf $DEST done
For sake of completeness hereby the trac-adminconsole script:
#!/usr/bin/python # -*- coding: iso8859-1 -*- __author__ = 'Daniel Lundin <daniel@edgewall.com>, Jonas Borgstr<F6>m <jonas@edgewall.com>' __copyright__ = 'Copyright (c) 2005 Edgewall Software' __license__ = """ Copyright (C) 2003, 2004, 2005 Edgewall Software Copyright (C) 2003, 2004 Jonas Borgstr<F6>m <jonas@edgewall.com> Copyright (C) 2003, 2004 Daniel Lundin <daniel@edgewall.com> All rights reserved. This software is licensed as described in the file COPYING, which you should have received as part of this distribution. The terms are also available at http://trac.edgewall.org/wiki/TracLicense. This software consists of voluntary contributions made by many individuals. For the exact contribution history, see the revision history and logs, available at http://trac.edgewall.org/log/.""" import sys from trac.admin.console import run sys.exit(run(sys.argv[1:]))