#!/usr/bin/bash
# author: Matthew Brown
# date: 2008-09-16
#---------------------------
# Variable Initialization
#---------------------------
cHour=`/usr/bin/date +%H`
#loc1=/var/local/backups/mysql_hourly
loc1=/mysql-backup/`hostname`/hourly
archBase=mysql_var-hour.
archNM=$archBase$cHour
dumpSpot=$loc1/$archNM
tempF=/tmp/mysqldumpStart
tempF1=/tmp/mysqldumpStart1
x=$(((`date +%H`) - 1 | bc))
fqdn=`/bin/hostname`
hostname=`basename $fqdn .usc.edu`
#--------------------------------------
# Record the mysqldump start time
#--------------------------------------
echo "Hourly mysql data backup began `date`"> $tempF &
#--------------------------------------
# Perform the mysqldump
#--------------------------------------
/var/local/mysql/default/bin/mysqldump --opt --force \
--user=root --password='notreally' --all-databases \
> $dumpSpot
#--------------------------------------
# Remove the previous day's hourly backup
#--------------------------------------
rm $dumpSpot.gz
#--------------------------------------
# Compress the backup using gzip
#--------------------------------------
/usr/bin/gzip $dumpSpot
#--------------------------------------
# Record long listing of new hourly backup
#--------------------------------------
ls -ltr $loc1/$archBase* > $tempF1
#--------------------------------------
# Compose and email backup completion report
#--------------------------------------
cat $tempF $tempF1 | mailx -s "$hostname `date +%Y.%m.%d` hour: `date +%H` mysql data dump complete" backup-reports
#--------------------------------------
# cleanup temp files
#--------------------------------------
rm $tempF $tempF1
Tuesday, September 16, 2008
Expanded version for hourly snapshots
I then expanded that version for hourly snapshots, with this as the result:
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment