Sure. Just create a new file called something like mysqlbackup.sh and chmod
it to make it executable. Change any of the vars you want, and it should
work (but remember to update the e-mail part of it to use whatever e-mail
client you want, unless you just want to leave that part out)

This is a customized script, so you'll probably need to tweak it to get it
right for you. <shrug>

#!/bin/sh

################################
# MySQL Backup Script          #
################################

# Tarfile Info
DATE=`/bin/date +%d-%b-%Y-%H-%M-%S`
FILEPREFIX="MySQL-Backup-$DATE"
TEMPDIR="/tmp"

# You can also use stuff like hostname:
# HOSTNAME=`/bin/hostname`
#
# As well as other date formats - check the
# man pages on the date command for different
# formats you can use.

# MySQL Info
USERNAME="root"
PASSWORD="password"
DATABASE="--all-databases"

# Email Info
RECIPIENT="[EMAIL PROTECTED]"
NICEDATE=`/bin/date +%b-%d-%Y`
SUBJECT="MySQL Backup for $NICEDATE"


# Do the tarring
mysqldump -u$USERNAME -p$PASSWORD $DATABASE > $TEMPDIR/$FILEPREFIX.sql
tar -cf $TEMPDIR/$FILEPREFIX.tar.gz -z $TEMPDIR/$FILEPREFIX.sql
rm -f $TEMPDIR/$FILEPREFIX.sql

# E-mail the tarfile - Use whatever e-mail method you
# want. I use perl, but another good one is biabam.
BackupMailer.pl $RECIPIENT "$SUBJECT" $FILEPREFIX.tar.gz

- Jonathan

-----Original Message-----
From: David McInnis [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 02, 2002 10:53 AM
To: 'Jonathan Hilgeman'; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: backup databases


Could you share your script for doing the date thing with the rest of
us?  That sounds useful.

David McInnis

-----Original Message-----
From: Jonathan Hilgeman [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, April 02, 2002 10:40 AM
To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
Subject: RE: backup databases

I regularly back up all my databases with mysqldump:

mysqldump -uUsername -pPassword --all-databases > tmp.sql && tar -cf
MySQL-Backup-DATE.tar.gz -z tmp.sql && rm -f tmp.sql

I use a script (to determine DATE) in conjunction with cron to back all
databases up nightly, and I also have the script e-mail the .tar.gz file
to
me so I can have a backup in case the server goes down. 

I've heard of hotcopy but never used it, so I couldn't recommend or
"unrecommend" it. 

- Jonahtan

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <mysql-unsubscribe-##L=##[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to