Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Backing up MySQL (was: Re: Drupal talk pdf and webcast)



Doug wrote:
> Hello:
> 
> Links for my talk on Drupal are up on Blu.org.  There is even 1 bonus
> slide that provides a few comments on service providers and backups.
> After the talk, I did a little more search on backups.  There is a
> module that makes backing up the mysql database just a few mouse
> clicks away.  One can still do the phpmyadmin way, but this approach
> automatically skips the cache files, a nice feature.

Here's how  I back up MySQL:

BACKDIR=/FOO/backups
DATE=`date '+%y%m%d'`
TARBALL=backup_mysql_${HOSTNAME}_${DATE}.tgz
BACKUP_DAYS=14

cd ${BACKDIR}

DATABASES=`echo "show databases" | mysql -uroot -pFOO -qN`

for DB in ${DATABASES} ; do
    mysqldump -uroot -pFOO --add-drop-table --databases ${DB} >
mysql_${DB}.sql ;
done

# Tar/gzip the individual files into one file
tar czf ${TARBALL} *.sql
chmod 700 ${TARBALL}
rm *.sql

# Remove old backups
if [[ -f ${TARBALL} ]] ; then
    find . -name "backup_mysql_${HOSTNAME}_"'*.tgz' -mtime
+${BACKUP_DAYS} | xargs -r rm
fi






BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org