Automated cPanel backup
A great man once said:
Only wimps use tape backup: real men just upload their important stuff on ftp, and let the rest of the world mirror it ;)
While it works for him, for us pure mortals this trick doesn’t get the job done. That’s why we have to use backups. Protecting your data is important. It’s almost vital that you keep a copy of your most important files in case your primary storage medium just dies on you. Or even worse: it gets hacked. Following my post about securing WordPress, I thought that when my blog got hacked I was lucky to have those files backed-up on my hard-drive which let me reduce the downtime involved by moving my blog to another host. I say lucky because only providence made me make a backup copy to my hard drive.
Since then I’ve decided to automate the backup process and this resulted in a beautifully crafted BASH script which should get the job done for everyone having a web hosting account with cPanel, one of the most popular web hosting administration panels. The script relies on the existence of several configuration files:
- main configuration file – holding global settings like the backup folder, log file, etc.;
- domain configuration file – a file for every domain a user holds on different accounts/servers with specific data for logging into cPanel and downloading the home directories and MySQL databases (add-on domains data can be downloaded with the primary domain’s). This file should have the same name as the domain (e.g. example.com).
For detailed information about setting up the system I encourage you to read the included README file and the comments from the configuration files. To run the script you just need to have the files set up according to your needs and call it like this:
./getCPANELbackups.sh
Of course you can fully automate your backups by creating a CRON job to call the script like this:
00 00 * * * /path/to/script/getCPANELbackups.sh
Since the domain configuration files hold sensible data (users and passwords) it’s better to assure that no other user on your system has access to them. This means that you must set up the file permissions to 600 (read/write only for your account):
chmod 600 example.com
For any complaints or feature requests, please drop a comment on this page. Backup often!
Similar Posts:
- Gitosis and read-only Git repositories
- How to install VMware Server 2.0.1 on Ubuntu 9.04 Jaunty Jackalope
- Securing WordPress from the ground up
- How to install Ubuntu Desktop Edition
- How to install Oracle Database 10g XE and OC4J on Ubuntu
1 Comment
Leave a comment
Secure your files
Recent Posts
Recent Comments
Radu said:
I think you have a corrupted archive. Try to download it again. more»
Ronny Ko said:
I have a gigabit Dlink card ( D-Link System Inc DGE-530T Gigabit Ethernet Adapter (rev 11) (rev 11)). When I first run... more»
al.zatv said:
Calin, thank you for your info. web face for virtualbox is the thing i was looking for. more»
djrise said:
Hi and thank you for your job, I have downloaded the script but when i execute them it said : sh vmware-server-2.0.x-kernel-... more»
Xr said:
Disabling vmci in the web access solved it: Select the VM–>ConfigurationR 11;>Advanced–>Conf iguration... more»
Recent Tweets
- jQuery .click() and the double submit of a form - http://bit.ly/dcCGqR [#]







If you are going to get a VPS server make sure that it has cPanel because it makes server maintenance easier.