How do I create a cron job to backup my MySQL database?

THIS INFORMATION IS PROVIDED AS A COURTESY SERVICE, IN ALL CASES WE SUGGEST MANUALLY DOWNLOADING AND VERIFYING DATABASE BACKUPS

To make it work create a file called backup.sh and put the following code in it:

#!/bin/sh
 mysqldump --opt -hDB_HOST -pDB_PASSWORD -uDB_USER DB_NAME > YOUR_WEB_ROOT/db_backup.sql
 
 gzip -f YOUR_WEB_ROOT/db_backup.sql
 
 tar czf YOUR_WEB_ROOT/web_backup.tgz YOUR_WEB_ROOT/web/content/

Place this file in your web root (as defined below) and create a cron job. Put the name backup.sh in the Command To Run Field, select Perl as the Command Language and then select when you want it to run.

In the script above everything in CAPS is something you need to replace. here is the descriptions of each:

YOUR_WEB_ROOT - This is the absolute path to your files. You can find this under Serverside paths that is in Wesites & Email -> Site -> Features. An example would be: /mnt/target02/123456/www.whatever.com
(notice that /web/content is not included in that path)

DB_HOST - Database Host an example would be mysql5-9.wc1

DB_PASSWORD - the password on this database

DB_USER - the database username

DB_NAME - the name of the database you are backing up

  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

How do I check my email account using webmail?

1. Go to webmail.yourdomain.com then sign in with your full email address and password (that you...

How do I create an email account?

1. Log in to your control panel (https://www.websitesettings.com/)2. Click on the website you...

What are the server paths?

Your server paths can be located by logging in to your control panel...

Do you support FrontPage Extensions?

Unfortunately we do not support FrontPage Extensions on our packages. Although many sites...

Are there any limits on how many times I can check my mail?

There are no limits on the number of POP3/IMAP checks you can make on a per hour or per domain...