BackupRT

From Request Tracker Wiki
Jump to: navigation, search

Introduction

The following script was written to provide a quick way to run a backup of the Request Tracker application installation. This is a good tool to use if you're hacking at templates and objects to ensure that you have a known good restore point.

Requirements

I wrote this for Debain Sarge/Stable and it depends on having the exim4 mailer installed. I also requires that there is a ''tmp'' dir in ''/root''. You can of course change this to whatever directory that you wish. I'll be refining this script as time permits.

Caveat Emptor

This script is provided with no warranties expressed or implied. Use your own risk. Milage may vary.

TODO

  • Add section to detect mailer and automatically set this envvar
  • Add automatic tmpfile cleanup #!/bin/bash # <h1>backupRT.sh</h1> # <h1>$Author: www-data $</h1> <h1>$Revision: 1.5 $</h1> <h1>$Id: backupRT,v 1.5 2006/04/10 15:55:01 www-data Exp $</h1> # <h1>Runs a file level backup of the contents of the following</h1> <h1>directories:</h1> # <h1>/usr/local/share/request-tracker3.4</h1> <h1>/usr/share/request-tracker3.4</h1> # <h1>Into a file named rtappbak-{date}.tar.gz</h1> # # <h1>Implementation Specific Variables</h1> # <h1>You can change this to another directory for the tmp files.</h1> <h1>I don't like to dump in /tmp</h1> SCRTMPDIR=/root/tmp/ MAILHEADER=$SCRTMPDIRrtbakfiles-mail rtbakWATCHER=###YOUREMAILADDRESSHERE### MAILSERVER=###YOUREMAILSERVERHOSTNAME### # <h1>Script Variables</h1> # curday=<code>date +"%Y%m%d%H%M%S"</code> prefn="rtappbak-" backdir=/var/backups/rt/ fullfn=$backdir$prefn$curday.tgz rtbakCHANGES_FILE=/root/tmp/rtbakfiles HOSTNAME=<code>/bin/hostname</code> FQDN=<code>/bin/hostname -f</code> fullFILENAME=<code>pwd</code>$fullfn # <h1>Make/Verify target dirs</h1> # if [ ! -d $backdir ]; then mkdir $backdir; fi if [ ! -d $SCRTMPDIR ]; then mkdir $SCRTMPDIR; fi <h1>do the backup</h1> tar cvzf $fullfn /usr/local/share/request-tracker3.4 /usr/share/request-tracker3.4 /etc/request-tracker3.4 <h1>get the file list and send to $rtbakCHANGES_FILE</h1> tar tvzf $fullfn > $rtbakCHANGES_FILE <h1>create message file and send to watcher</h1> if [ -s $CHANGES_FILE ] ; then echo HELO $MAILSERVER > $MAILHEADER echo MAIL FROM:root@$FQDN >> $MAILHEADER echo RCPT TO:$rtbakWATCHER >> $MAILHEADER echo DATA >> $MAILHEADER echo Subject: $HOSTNAME RT Application Backup >> $MAILHEADER echo Backup of files from the RT install on ${HOSTNAME}: >> $MAILHEADER echo This file is located at: >> $MAILHEADER echo ${HOSTNAME}:$fullFILENAME >> $MAILHEADER echo >> $MAILHEADER cat $rtbakCHANGES_FILE >> $MAILHEADER echo . >> $MAILHEADER echo QUIT >> $MAILHEADER exim4 -bs < $MAILHEADER fi

Rev 40 Notes: Cleaned up variable declarations and added target directory checking/creation.

MichaelErana g33k (at) efamilynj.org