<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=BackupRTDB</id>
	<title>BackupRTDB - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=BackupRTDB"/>
	<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=BackupRTDB&amp;action=history"/>
	<updated>2026-08-21T19:04:25Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=BackupRTDB&amp;diff=326&amp;oldid=prev</id>
		<title>Admin: 3 revisions imported</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=BackupRTDB&amp;diff=326&amp;oldid=prev"/>
		<updated>2016-04-06T20:03:19Z</updated>

		<summary type="html">&lt;p&gt;3 revisions imported&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Introduction&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The following script was written to provide a quick way to run a backup of the Request Tracker &amp;#039;&amp;#039;mysql&amp;#039;&amp;#039; database. This is a good tool for routine daily backups and can be run as part of the daily cron batch.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Requirements&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt; I wrote this for Debain Sarge/Stable and it depends on having the exim4 mailer installed. I also requires that there is a &amp;#039;&amp;#039;tmp&amp;#039;&amp;#039; dir in /root. It also assumes that &amp;#039;&amp;#039;root&amp;#039;&amp;#039; (or what ever account the cron job will run as) will have DB access rights to the RT Database. &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Caveat Emptor&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This script is provided with no warranties expressed or implied. Use your own risk. Milage may vary.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;TODO&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* Add section to detect mailer and automatically set this envvar&lt;br /&gt;
* Add automatic tmpfile cleanup&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;#!/bin/bash&lt;br /&gt;
  #&lt;br /&gt;
  # backupRTDB.sh&lt;br /&gt;
  #&lt;br /&gt;
  # $Author: www-data $&lt;br /&gt;
  # $Revision: 1.3 $&lt;br /&gt;
  # $Id: backupRTDB,v 1.3 2006/04/10 15:48:21 www-data Exp $&lt;br /&gt;
  #&lt;br /&gt;
  # Runs a mysqldump backup of the contents of the&lt;br /&gt;
  # RT Database.&lt;br /&gt;
  #&lt;br /&gt;
  # Into files named rtdb-main-{date}.tar.gz&lt;br /&gt;
  #                  rtdb-attach-{date}.tar.gz&lt;br /&gt;
  #&lt;br /&gt;
  # This script assumes that root can login to mysql locally&lt;br /&gt;
  # without a password. If you change this then you will need to revise&lt;br /&gt;
  # the connection strings.&lt;br /&gt;
  #&lt;br /&gt;
  &lt;br /&gt;
  #&lt;br /&gt;
  # Implementation Specific Variables&lt;br /&gt;
  #&lt;br /&gt;
  # You can change this to another directory for the tmp files.&lt;br /&gt;
  #  I don&amp;#039;t like to dump in /tmp&lt;br /&gt;
  SCRTMPDIR=/root/tmp/&lt;br /&gt;
  MAILHEADER=$SCRTMPDIRrtbakfiles-mail&lt;br /&gt;
  rtDB=###YOURRTDATABASENAME###&lt;br /&gt;
  rtbakWATCHER=###YOUREMAIL###&lt;br /&gt;
  MAILSERVER=###YOUREMAILSERVER###&lt;br /&gt;
  rtUSER=###YOURRTUSERNAME###&lt;br /&gt;
  &lt;br /&gt;
  #&lt;br /&gt;
  # Script Variables&lt;br /&gt;
  #&lt;br /&gt;
  curday=`date +&amp;quot;%Y%m%d%H%M%S&amp;quot;`&lt;br /&gt;
  backdir=/var/backups/rt/&lt;br /&gt;
  mainprefn=&amp;quot;rtdb-main-&amp;quot;&lt;br /&gt;
  attachprefn=&amp;quot;rtdb-attach-&amp;quot;&lt;br /&gt;
  mainfullfn=$backdir$mainprefn$curday.gz&lt;br /&gt;
  attachfullfn=$backdir$attachprefn$curday.gz&lt;br /&gt;
  rtdbbakCHANGES_FILE=$SCRTMPDIRrtbakfiles&lt;br /&gt;
  HOSTNAME=`/bin/hostname`&lt;br /&gt;
  FQDN=`/bin/hostname -f`&lt;br /&gt;
  rtMainTables=&amp;quot;ACL Attributes CachedGroupMembers CustomFieldValues CustomFields GroupMembers \&lt;br /&gt;
  Groups Links ObjectCustomFieldValues ObjectCustomFields Principals Queues ScripActions \&lt;br /&gt;
  ScripConditions Scrips Templates Tickets Transactions Users sessions&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  #&lt;br /&gt;
  # Make/Verify target dirs&lt;br /&gt;
  #&lt;br /&gt;
  if [ ! -d $backdir ]; then&lt;br /&gt;
    mkdir $backdir;&lt;br /&gt;
  fi&lt;br /&gt;
  &lt;br /&gt;
  if [ ! -d $SCRTMPDIR ]; then&lt;br /&gt;
    mkdir $SCRTMPDIR;&lt;br /&gt;
  fi&lt;br /&gt;
  &lt;br /&gt;
  # do the Main backup&lt;br /&gt;
  mysqldump $rtDB --opt $rtMainTables  | gzip &amp;amp;gt; $mainfullfn&lt;br /&gt;
  &lt;br /&gt;
  # do the Attachment backup&lt;br /&gt;
  mysqldump $rtDB --opt --default-character-set=binary Attachments  | gzip &amp;amp;gt; $attachfullfn&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  #create message file and send to watcher&lt;br /&gt;
  if [ -s $CHANGES_FILE ] ; then&lt;br /&gt;
    echo HELO $MAILSERVER &amp;amp;gt; $MAILHEADER&lt;br /&gt;
    echo MAIL FROM:root@$FQDN  &amp;amp;gt;&amp;amp;gt; $MAILHEADER&lt;br /&gt;
    echo RCPT TO:$rtbakWATCHER &amp;amp;gt;&amp;amp;gt; $MAILHEADER&lt;br /&gt;
    echo DATA &amp;amp;gt;&amp;amp;gt; $MAILHEADER&lt;br /&gt;
    echo Subject: $HOSTNAME - $curday - RT Database backup &amp;amp;gt;&amp;amp;gt; $MAILHEADER&lt;br /&gt;
    echo Backup of files from the RT install on ${HOSTNAME}: &amp;amp;gt;&amp;amp;gt; $MAILHEADER&lt;br /&gt;
    echo This file is located at: &amp;amp;gt;&amp;amp;gt; $MAILHEADER&lt;br /&gt;
    echo ${HOSTNAME}:$mainfullfn &amp;amp;gt;&amp;amp;gt; $MAILHEADER&lt;br /&gt;
    echo &amp;amp;gt;&amp;amp;gt; $MAILHEADER&lt;br /&gt;
    echo . &amp;amp;gt;&amp;amp;gt; $MAILHEADER&lt;br /&gt;
    echo QUIT &amp;amp;gt;&amp;amp;gt; $MAILHEADER&lt;br /&gt;
    exim4 -bs &amp;amp;lt; $MAILHEADER&lt;br /&gt;
  fi&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[MichaelErana]] &amp;lt;u&amp;gt;g33k (at) efamilynj.org&amp;lt;/u&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>