Scott -

Throw in some error checking - it can't hurt. Also, do a check to see
if the MySQL database is online (you never know) before trying to back
up the database within. Here's an example:

/path/to/mysqladmin --user=$USER --password=$PASS ping | grep "mysqld
is alive" >/dev/null 2>&1
if [ $? = 0 ]; then
  echo "alive"
else
  echo "dead!"
  exit 1
fi

Use the "if [ $? = 0 ]" after all of your commands (ie smbmount,
mysqldump, etc) to check for errors. You may also want to do a 'rm -f'
instead of just 'rm'.

Just my two cents. Hope this helps.

Greg

On 7/19/07, Scott Hill <[EMAIL PROTECTED]> wrote:
On 7/18/07 5:58 PM, "John Schubert" <[EMAIL PROTECTED]> wrote:

> Now to go back and do the
> tutorial on DB back up and do it myself, and then
> figure out how to automate pushing it to another place
> on an all Microsoft shop (on which I have no
> permissions anywhere).

I just had to figure this out myself. Here's the script I worked up, with
some help from the wiki. Cron kicks it off every night. It's been running
correctly for a few days...

I'm no shell scripting expert, and there's no error catching whatsoever
right now. All the usual warnings apply: no guarantees, no warranties, YMMV.
And of course, everyone, feel free to tell me exactly where I made horrid
mistakes!

----- CUT HERE -----
#!/bin/bash
#
# rtbackup.sh
# Backup RT database & config files
# Scott Hill, 7/16/2007
# Based in part on backupRT.sh by Michael Erana
#   (http://wiki.bestpractical.com/view/backupRT)

#
# Script Variables
#
SCRTMPDIR=/etc/request-tracker3.6/backup
dumpfile=rtdb-`date +%Y%m%d`.sql
rtdbuser=rtuser
rtdbpwd=password
rtdbname=rt
backupshare=//server/share
backupmountpoint=/mnt/server
shareuser=username
sharepass=password
backupdir=/mnt/server/backups
backupfn=rtbackup.zip

#
# Mount backup target volume
#
smbmount $backupshare $backupmountpoint -o
username=$shareuser,password=$sharepass

#
# Make/Verify target dirs
#
if [ ! -d $backupdir ]; then
  mkdir $backdir;
fi

if [ ! -d $SCRTMPDIR ]; then
  mkdir $SCRTMPDIR;
fi

#
# Rename any existing files, keeping a week's worth of files
#
rm $backupdir/$backupfn.6
mv $backupdir/$backupfn.5 $backupdir/$backupfn.6
mv $backupdir/$backupfn.4 $backupdir/$backupfn.5
mv $backupdir/$backupfn.3 $backupdir/$backupfn.4
mv $backupdir/$backupfn.2 $backupdir/$backupfn.3
mv $backupdir/$backupfn.1 $backupdir/$backupfn.2
mv $backupdir/$backupfn $backupdir/$backupfn.1

#
# MySQL dump
#
mysqldump --opt --add-drop-table --single-transaction -u $rtdbuser \
-p$rtdbpwd $rtdbname > $SCRTMPDIR/$dumpfile

#
# Zip up the dumpfile and the /etc/request-tracker3.6 dir
#
zip -9 $backupdir/$backupfn $SCRTMPDIR/$dumpfile /etc/request-tracker3.6/*

#
# Cleanup
#
rm $SCRTMPDIR/$dumpfile
smbumount $backupmountpoint

----- CUT HERE -----


--
Scott Hill <[EMAIL PROTECTED]>
Network Administrator
Metro Dentalcare
(612) 861-9119

_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: [EMAIL PROTECTED]


Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: [EMAIL PROTECTED]


Discover RT's hidden secrets with RT Essentials from O'Reilly Media. Buy a copy at http://rtbook.bestpractical.com

Reply via email to