Mysql hourly backup using cron

I wanted a cron job to run that would backup my Mysql database each hour. But I also wanted the command to create a new file each time preserving the history.

This is the command I came up with:

mysqldump --opt -u [username] [dbname] > /path/to/backups/database-`date +%Y-%m-%d-%k:%M:%S`.sql

Leave a Reply

Your email address will not be published. Required fields are marked *

*

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=""> <strike> <strong>