Website backup

Do you want to backup your site and/or database? Check out this guide!

This is one of the ways I use Mozy backup. I've been meaning to write this for a long time, but never got the chance. You need to be familiar with ftp, cpanel, a bit of scripting, but it's not hard at all, google knows everything :-) And make sure you don't run out of space on your web account.

The backup process has 2 parts:

  1. on your server
  2. on your PC

First create an ftp account and give as home a directory outside the public_html. Asuming you're using cpanel it will look something like this:

remove the "public_html/" part from the Directory. I'm doing this because I don't want the backups directory to be accessible via web. Keep the account settings somewhere, you'll need them later.

Next make a script which will create an archive of your directory or directories of choice. Let's call it pub-html-bk.sh

rm /home/USERNAME/bkp11/site-backup.tgz
tar -czf /home/USERNAME/bkp11/site-backup.tgz --exclude '*.avi' --exclude '*.flv' --exclude '*.wmv' --exclude '*.mp3' --exclude 'tmp' --exclude 'core' --exclude 'SOMEADDONSITE.com' /home/USERNAME/public_html

Save it in /home/USERNAME and make it executable. As you can see, I've excluded some files, directories, even 1 addon domain, which I can backup separately and I will backup the public_html dir. The archive will be saved in /home/USERNAME/bkp11/site-backup.tgz

In the same script you can also add commands to dump your mysql databases one by one.

Then create a cron job, the command will be

/bin/bash /home/USERNAME/pub-html-bk.sh

I run the script once a day or once a week, depends on how often the content changes.

The 2nd part takes place on my PC. Coming soon!