Share

Want to automate the backup of you site and it’s database?  Here are the instructions for you:

To make the cron job work, create a file called backup.sh and place the following code inside of it ::

 #!/bin/sh
mysqldump -h DB_HOST -u DB_USER -p'DB_PASSWORD' 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/

In the above script, you will need to replace the portions in ALL CAPS with your actual information as follows :

YOUR_WEB_ROOT – This is the absolute path to your files. You can find this path by Going to your hosting control panel, click the site you want to work with, the click Features, and scroll down. This will be the “Linux Path” listed there. An example would be: /mnt/target02/123456/www.domain.com (Note, the /web/content is not included in that path)

DB_HOST – Database Host an example would be mysql5-9.wc1 or mysql50-78.wc1.dfw1.stabletransit.com

DB_PASSWORD – the password on this database (note the single quotes and that there is no space between the -p and the single quote)

DB_USER – the database username (e.g.: 12345_username)

DB_NAME – the name of the database you are backing up (e.g.: 12345_database_name). Note that there is no parameter for this option unlike the previous examples (-h -p and -u respectively).
Place this file in your web root and create a cron job.

To create the cron job:

  1. Go to your hosting control panel.
  2. Select the website you want to work with.
  3. Click the Features tab.
  4. Scroll down to the Scheduled Tasks (Cron Jobs) area.
  5. Click on Add New Task. Put the name of the file, which, in our example is backup.sh in the “Command To Run Field”.
  6. Select Perl as the Command Language and then select the interval in which you wish to run your backup script.
Share

Dawn McCarroll

ADWH.COM strives to be the Internet web hosting company that small business and non-profit organizations rely on to meet their web site hosting and Internet business needs. We offer a full range of hosting options and tools and can customize a plan for any need.
   

Please visit our advertisers!

UnCommon Courtesy's Charity Bingo