Skip to content

Automatic cPanel Backup via Curl&Cron

[UPDATE2 2012-03-14] Use Automatic Dropbox backup instead.

[UPDATE 2008-05-20] Please see the updated version for this script

Justin Cook wrote an article how to backup your cPanel stuff with PHP&Cron. Well, the PHP part didn't really work for me, so I had to create an alternative approach.

Enter curl.

Put the following in an executable file (or download it) and include it in your crontab. It creates a full backup of your cPanel account (that can be restored via cPanel) and uploads it to another server via SCP (although you may choose to use FTP).

#cPanel info CP_USERNAME=username CP_PASSWORD=password CP_SKIN=x3 #plain "x" is probably the most used one #SCP/FTP info CP_SCP_USER=username CP_SCP_PASS=password CP_SCP_MODE=scp #see cPanel backup page for alternatives #CP_SCP_PORT=65321 #if you have a non-standard port #if you want to put the backups somewhere smart, #remove comment from the CP_SCP_RDIR line and #make sure the directory exists #CP_SCP_RDIR=web_backup%2F$CP_DOMAIN%2F # url encoded, e.g. "/" equals "%2F" #make sure this command (starting with curl, ending with dev/null) is on one line curl --silent --insecure --user $CP_USERNAME:$CP_PASSWORD -d "dest=$CP_SCP_MODE&email=$CP_EMAIL&server=$CP_SCP_HOST&user=$CP_SCP_USER&pass=$CP_SCP_PASS&port=$CP_SCP_PORT&rdir=$CP_SCP_RDIR" https://$CP_DOMAIN:2083/frontend/$CP_SKIN/backup/dofullbackup.html > /dev/null CURL_EXIT=$? if [ $CURL_EXIT -gt 0 ]; then echo curl returned exit status $CURL_EXIT - see curl manual pages for more details exit 69 fi # ok exit 0 

I wanted to have several of these files centrally manageable somewhere, but had to put each file on the system that was backed up. I guess it has something to do with server specifications.

One Trackback/Pingback

  1. [...] few months back I posted a shell script for backing up your cPanel account automatically using cron and curl. I updated the file a bit, and now it creates files with monthly names (for me, at [...]