
I believe the script could be fairly easily edited to allow separate passwords for each account, but I just haven’t bothered. You can generate that API key within your WHM panel using the “Manage API Tokens” section:Īs of right now, the only downside with this script is that ALL cPanel user accounts must use the same password in order to be backed up.

I’ve bolded the text above, in all the locations where you need to replace the values with your own inputs.įor the above script to work, you’re going to need a WHM API Key so that the script can gain access to all your cPanel accounts. you may want to add some logging here. $result = file_get_contents($url, false, $context) $context = stream_context_create($options)

'header' => "Content-type: application/x-www-form-urlencoded\r\nAuthorization: Basic $auth\r\n", #loop through accounts, create backup, upload $accounts = json_decode($response, true) To save response in a variable from server, set headers Ĭurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) Ĭurl_setopt($ch, CURLOPT_HTTPHEADER, $headers) From there, I have it set to run once per week: :2087/json-api/listaccts?api.version=1&want=user,domain" Create a PHP file called “backup.php”, and save it to the main hosting account inside your WHM panel. The second script then takes that backup, and automates the upload from my reseller server to an S3 bucket for safe keeping.
Cpanel whm backup full#
The first script generates a tar file with a full backup of the site (including all files and database dumps). Searching Google didn’t come up with much, so instead, I generated my own two-part script.īoth of these scripts are scheduled via cronjob.
Cpanel whm backup manual#
And I currently have around ~75 clients, which would make it very difficult for me to take manual backups of each website on a weekly basis. cPanel offers a way to take backups, but it’s not automated. I, too, had this problem when I first began selling hosting accounts.

However, one of the most frequent questions I get is “ How can I automate backups in cPanel?” To my surprise, that playlist has blown up, and many people have found it incredibly useful. Right now, a couple thousand dollars per month passively. I built a playlist on YouTube, talking about how I earn passive income by selling hosting accounts via a Reseller.
