#!/bin/sh
#
#  Database backup script.
#
#  Execute with a command line argument of the name of the
#  database that you want to back up
#

DEST_DIR=/path/to/where/you/want/saved/file

DBMS_HOME=/same/path/you/used/during/install
DATADIR=$DBMS_HOME/data
EXECDIR=$DBMS_HOME/mysql/bin

# get the database info
$EXECDIR/mysqldump --defaults-file=$DBMS_HOME/scripts/my.cnf \
   -uBACKUP_USER -pBACKUP_PASS --flush-logs --lock-tables --quick \
   $1 | gzip -9 > $DEST_DIR/$1/$1Dump`date +%m%d`.gz

# get rid of the old log files since we don't need them around anymore.
# keep em for a week or so just in case we have all left the office and
# aren't in for a while
find $DATADIR -name "YOUR_MACHINE_NAME.[0-9]*" -type f -mtime +7 | xargs rm -f
find $DATADIR -name "YOUR_MACHINE_NAME-bin.[0-9]*" -type f -mtime +7 | xargs rm -f

# get rid of the old backups after they have been here a WHILE.  No need
# to delete these things right away.
find $DEST_DIR -name "$1Dump[0-9]*.gz" -type f -mtime +90 | xargs rm -f    
 

