MySQL Backup Shell Script
Many of my clients need a quick backup solution before we implement anything on a larger more permanent scale. I wrote this simple script that simply make a copy of a database and then created a timestamped tarball of the file.
#!bin/sh
date=`date +%Y-%m-%d_%Hh%M`
cd /my/path/for/backups/
mysqldump -umy_user -p"mypass" my_database > $date.sql
tar -zcvf $date.tgz *.sql
# uncomment this line to import the sql into another database, for example as a mirror
#mysql -umy_user -p"mypass" mirror_database < $date.sql
rm *.sql
Then, just setup a cron job to run this at whichever interval you want this to run.