CPanel Site Auto-Backup

A while back I was looking for a way to backup my cPanel-based websites and databases and I don't really dig the idea of huge daily backups taking up space on the same partition I'm trying to protect. Enter CPSafe. Using a combination of shell scripts and cron, CPSafe backs up all your cPanel-managed sites/databases and offloads them to an FTP server. Using CPSafe saves space on your server because backups are generated on the fly using wget and you don't have to enable backups within cPanel.

License

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.

Requirements

Install Steps

1) Untar the bundle:

$ gzip -d xvf cpsafe_v0.8.tar.gz
$ tar xvf cpsafe_v0.8.tar

2) Edit cpsafe.conf to suit your needs

$ vi cpsafe.conf

3) Add scripts to cron (see example.cron for help)

$ crontab -e

Sample Crontab

CPSafe requires a minimum of two cron entries for full site and database backup:

1) Database Backup (one per cpanel user, i.e per site)
2) Website Backup (one per cpanel user, i.e per site)

Make sure you customize cpsafe.conf before adding these entries to cron. When you're ready, copy the commands into cron using 'crontab -e'.
For more information about cron - go here: http://www.scottahearn.com/links_crontab.php

/images/error.png WARNING

This method of automated backups requires that you store your CPanel login ID and password in crontab in plain text. Stored passwords are inherently insecure but automated backups using this method are impossible otherwise. Continue at your own risk.

Examples entries for each step are found below:

#--------------------------------------------------------------------------------------
# Modify the following cron entries and add them to the crontab for automated backups.
# --------------------------------------------------------------------------------------

# 1) Generate DB backup on Wednesday(3) at 1 AM
0 1 * * 3 cd /home/username/cpsafe/databases; ./pull_db_backup.sh username userpass usersite.com >> /home/username/cpsafe/cpsafe.log

# 2) Generate usersite.com site backup on Thursday(4) at 1 AM
0 1 * * 4 cd /home/username/cpsafe/websites; ./pull_site_backup.sh username userpass usersite.com >> /home/username/cpsafe/cpsafe.log

Help / Contact

The code is brand new and considered beta. I've tested it on a couple systems but it's not guaranteed to work everywhere.

Comments

CPanel Site Auto-Backup

really informative post. learnt quite a lot. thanks a lot for sharing. keep it up.
The community of braindumps. Making people successful in a challenging world.