[rt-users] backing up db

Bertrand Delacretaz bdelacretaz at codeconsult.ch
Thu Apr 5 10:54:41 EDT 2001


FWIW, here's a script that I wrote to have my RT server send me a mail with 
the contents of the database + text files. Will probably need some hacking if 
you want to use it on your system.

THIS_SCRIPT=$0
MAILADDR="rt-backup at codeconsult.ch"
RTFILES=/var/rt
MYSQLDUMP="mysqldump -uroot -pzesecret rt"
DATE=$(date +%Y%m%d-%H%M%S)
 
# make sure tmp files are deleted on exit
cleanup()
{
        rm $TMPSQL $TMPTAR $TMPTAR.gz 2>/dev/null
}
 
trap 'cleanup' 0 1 2 15
 
# create a compressed tar file of the mysql data
TMPSQL=/tmp/rt-data-$DATE-.sql
$MYSQLDUMP > $TMPSQL
 
# tar this together with RT transaction data
# and compress the result
TMPTAR=/tmp/rt-backup-$DATE.tar
tar cf $TMPTAR $TMPSQL $RTFILES $THIS_SCRIPT
gzip $TMPTAR
 
# uuencode the result
TMPUU=/tmp/rt-uuencode-$DATE.tar
uuencode $TMPTAR.gz <$TMPTAR.gz > $TMPUU
 
# mail result to backup receiver
mail -s "rt-backup-$DATE" $MAILADDR < $TMPUU  

-- 
 -- Bertrand Delacrétaz, www.codeconsult.ch
 -- web technologies consultant - OO, Java, XML, C++





More information about the rt-users mailing list