Backing Up MySQL Databases

Most customers will know that we always remind them to make their own backups, it’s for their own peace of mind as our current service doesn’t offer backups (we say current because as of today that is very much a “watch this space”).

Backing up your files is often as simple as having the copy you’ve recently uploaded to your website on your home PC, or being able to reinstall the software from the wherever you installed it before. Databases aren’t quite so easy….

Let’s start simply, here’s how you can get a copy of your database dropped into your home directory on a daily or weekly basis.

Daily/Weekly Backup
1. Using your cPanel navigate your way to cron jobs.
2. Choose the “Advanced (Unix Style)” layout.
3. You’ll have some options to fill out here:

Minute: ?? Set this to an appropriate minute past the hour, we don’t give an example so everyone doesn’t set it for the same time!
Hour: ?? Set this for the hour time you want the backup to be done (overnight UK is usually best!)
Day: * Putting a * in here will cause this to be run every day of the week.
Month: * Putting a * in here will cause this to be run every month.
Weekday: ?? 0 would run every sunday, * would run every day

Now we get on to the command:
mysqldump –opt -Q -u dbusername –password=dbpassword dbname > /pathto/backups/sunday.sql

dbusername is the name of your database user (prefixed with your cPanel username).
dbpassword is the password to your database.
dbname is the name of your database (prefixed with your cPanel username).
/pathto/backups/sunday.sql is the path to the file /home/username/something.sql.

This should provide you with either a weekly or daily backup of your MySQL data in your home directory.

Leave a Reply

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