Create a Post-Backup script for WHM to S3

Primary tabs

If you have a WHM/cPanel based server, then you probably already have a daily backup running that keeps daily, weekly and monthly backups in another folder. But this does not help if the server disappears - you also need an offsite backup and Amazons S3 is perfect for this.

The good news is that there already exists a 'hook' that is run after an cPanel backup that we can use to do this.

Note: The functionality already exists to FTP backups to an external FTP server.

First you need to set up backups in WHM

  1. Log into WHM
  2. Select Backups -> Configure Backup
  3. Backup Status = "Enabled"
  4. Select time frames and other options as desired.
  5. Backup Destination = "/backup"

Now we need to write our hook script. SSH into your server as root.

touch /scripts/postcpbackup

chmod +x /scripts/postcpbackup

vim /scripts/postcpbackup

add these lines. You will need to get your amazon keys and setup a target bucket from the AWS site

export AWS_ACCESS_KEY_ID=xxx export AWS_SECRET_ACCESS_KEY=xxx s3sync -v -r --delete /backup/cpbackup/daily/ bucketname:daily/

And all done.

You can manually run the backup with

/scripts/cpbackup

and check that it has synchronised your daily backup to the S3 bucket when finished.

As a final note,

  • This backup does every single setting, file and log file for a cpanel account and so *should* be fully recoverable.
  • It only keeps the last copy (for disaster recovery - ie. your server explodes) and not older copies (for error recovery). These are kept on the server itself depending on how you configured the WHM backup.

 

Your IP Info

IP Address Locator

Speed Test

Test how fast your Internet connection really is.

DropBox

Use this link to get DropBox http://db.tt/iQHWaaF