How to backup your cpanel account on a shared server

I love cpanel. Its easy to use, cheap to run, stable and reliable. However given the nature of the internet and that there is always som crim out there who wants to steal your data or just plain mess with you, you have to make sure that you have a backup of your data.

Most hosts will make a weekly or monthly backup of your cpanel data (if they dont then MOVE HOST!!) however taking your own periodical backup can do no harm.

Just make sure you check with your host first to see if they allow you to take regular backups using this method and dont do hourly backups, you will eat through your bandwidth limit in no time.

Below (FIG 1) is some script I am using for a few of my clients and after some tweaking, it works great. It creates a FULL cpanel backup for your account and sends it to a remote ftp server so in the event something happens to your site, then you can transfer the backup and do a full cpanel restore.

Just do the following:

  1. login to cpanel and go to file manager
  2. once you are in file manager, create a new file ABOVE the /www/ folder
  3. call the file something like “my-daily-cpanel-backup.php
  4. copy and paste the code from FIG 1 into that file
  5. edit your cpanel settings and ftp setting and save

Now you need to set a cron job so that it calls the file up and make the backup.

  1. go back to cpanel home and look for the cron button
  2. add a new cron job as in FIG 2 and FIG 3 below.

FIG 1
Copy this code into the file you made ABOVE the /www/ directory.
{code codetype=php}

{/code}

FIG 2:
Create a cron job inside cpanel.

FIG 3:
The following variations of cron job can be used on various servers. Just drop this into the command section of your cron job making sure you put the right path to the file.
{code}
php -q /home/your_cpanel_username/my-daily-cpanel-backup.php
{/code}