Scheduled MySQL database backup

Assume that you are using crontab to schedule your task which you are using Unix system.

To schedule a database backup, it will be very easy as step below.

1. Log into your SSH.
2. Type “crontab -e” without quote.
3. Enter the command below.

0 0 * * * date=`date -I` ; mysqldump -a -u[user] -p[password]  [dbname] | gzip > /path/folder/[dbname]_$date.sql.gz

where you shall replace the user, password and dbname to your database information.

With the command as above it will actually backup your database by 12.00AM daily and place to the desired path and name with date.

Published by

Mick Genie

Mick Genie is the founder of and working at ExaBytes Network Sdn Bhd and WPWebHost web host company. He is expertise in Windows and Linux environment especially web hosting related information, tips and trick as well as the IT Information.