Client cPanel Backup Issue after updating to latest theme

Nov 4, 2022
2
2
3
India
cPanel Access Level
Reseller Owner
Hi everyone.

I have a question from a client, they used to backup their cPanel using the below pasted script but it has stopped working for them. They have switched to the new theme now and the remote backups have stopped using this script. How to fix this for them, kindly help...

-----------
$theme = 'paper_lantern'; // Must match current selected cPanel theme ('paper_lantern' in the majority of cases, 'x3' is possible as well)
-----------


---------------

<?php
// Settings
$cpaneluser = ''; // cPanel username
$cpaneluserpass = ''; // cPanel password
$theme = 'paper_lantern'; // Must match current selected cPanel theme ('paper_lantern' in the majority of cases, 'x3' is possible as well)
$ftp = true; // If it's false the backup will be stored in user's home directory, otherwise it will be uploaded via FTP to some custom location
$ftpserver = ''; // Must be localhost for current server or custom hostname for remote FTP upload
$ftpusername = ''; // cPanel/SFTP username. Should be the same as cPanel username for local upload or custom for remote upload
$ftppassword = ''; // cPanel/SFTP password. Should be the same as cPanel password for local upload or custom for remote upload
$ftpport = '21'; // SFTP port. Should be 21 in most cases.
$ftpdirectory = '/backup_dir'; // Directory on FTP server to store backups. MUST EXIST BEFORE BACKUP OR BACKUP PROCESS WILL FAIL

// Do not edit below this line
$domain = 'localhost';
$secure = true;
$auth = base64_encode($cpaneluser . ":" . $cpaneluserpass);
if ($secure) {
$url = "ssl://" . $domain;
$port = 2083;
} else {
$url = $domain;
$port = 2082;
}
$socket = fsockopen('localhost', 2082);
if (!$socket) {
exit("Failed to open socket connection.");
}
if ($ftp) {
$params = "dest=ftp&server=$ftpserver&user=$ftpusername&pass=$ftppassword&port=$ftpport&rdir=$ftpdirectory&submit=Generate Backup";
} else {
$params = "submit=Generate Backup";
}
fputs($socket, "POST /frontend/" . $theme . "/backup/dofullbackup.html?" . $params . " HTTP/1.0\r\n");
fputs($socket, "Host: $domain\r\n");
fputs($socket, "Authorization: Basic $auth\r\n");
fputs($socket, "Connection: Close\r\n");
fputs($socket, "\r\n");
while (!feof($socket)) {
$response = fgets($socket, 4096);
// echo $response; //uncomment this line for debugging
}
fclose($socket);

---------------

Thanks

Alex M.
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
16,505
2,605
363
cPanel Access Level
Root Administrator
Hey there! Editing custom PHP like this isn't something that we'd support on our end, but it looks like their script is just emulating a button click in the cPanel interface. That's not a recommended way to take backups, but I suppose it would work.

The current interface for the cPanel >> Backups page is inside frontend/jupiter/backup/index.html so they'd just need to update their theme detection line and the exact button click they want to happen in the interface.