Nov 142009
I wouldn’t deploy this as is but here is a good starting point. Tweek to fit and cron.
#!/bin/bash
### MySQL Server Login Info ###
MUSER="USER"
MPASS="PASSWORD"
MHOST="localhost"
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
BAK="./dumps"
GZIP="$(which gzip)"
NOW=$(date +"%Y-%m-%d")
[ ! -d $BAK ] && mkdir -p $BAK/$NOW || /bin/rm -f $BAK/*
DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')"
for db in $DBS
do
FILE=$BAK/$NOW/$db.$NOW.gz
$MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE
done
Sorry, the comment form is closed at this time.