Backing up your mysql on linux box per each database


#!/bin/bash
MUSER="root"
MPASS="password"
MHOST="localhost"
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
BAK="/mnt/backupdir"
GZIP="$(which gzip)"
NOW=$(date +"%d_%m_%Y")
for i in `find $BAK -ctime +22`; do rm $i; done
[ ! -d $BAK ] && mkdir -p $BAK
DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')"
for db in $DBS
do
 FILE=$BAK/$db.$NOW.gz
 $MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE
done


it deletes every 22 days old backups if you want to change life-time,
you can change the value of ctime in the followed line: for i in `find $BAK -ctime +22`; do rm $i; done

Backup your Mysql databases installed on windows with a batch file and task scheduler

If you have mysql running on windows platform for example for development/testing purposes, you are probably encountered the backing up issue
here are small bat file that can help you.

First of all you will need 7-zip for archiving SQL dumps, you can download it and use for free, from here

Then

( More... )