Are you backing up your MySQL database regularly?

Here's how to easily backup a MySQL database:

1. Create Folders

Make a folder called "backups", and then "daily" inside that.

2. Create Backup Script

Create a file in /backups called backup_daily.sh. Use the script below for the contents (make sure to change the words in capital letters to your MySQL connection settings).

Here's the code to use:

#!/bin/sh

echo 'Backing up MySQL database'

set -x

mysqldump --verbose --complete-insert -c -h HOSTNAME --user USERNAME --password=PASSWORD DATABASENAME > daily/$(date +%y-%m-%d).sql

gzip daily/$(date +%y-%m-%d).sql

3. Create Cron Job

Create a new cron job with this command: "cd backups && sh backup_daily.sh".

Note that the above command might have to be changed a bit depending on your hosting set up. For example, on Dreamhost the command would be "cd home/username/backups && sh backup_daily.sh".

You can enter cron by typing cron -e at the command line. Some hosting companies provide a cron job management tool that might be easier to use.