Mysqldump all databases and gzip

So, quick and simple MySQL backup in a CRON.

#!/bin/bash
_hour=`date '+%H'`;
_user="root";
_pass="thepassword";
_dest="/srv/backups/daily/";
mysqldump -u $_user -p$_pass --all-databases --ignore-table=mysql.event | gzip > $_dest_$_hour.sql.gz

I’ve used this in an hourly CRON so that I always have 24 hours of backups.

Note: The ignore of mysql.event is to stop an annoying new feature of a later version of MySQL that seems to report a notice that its skipped this table. I don’t really need it so I am ignoring it.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>