Reputation: 1261
I've been using the same backup cPanel backup script for a year and a half without fail and suddenly it stopped working without generating errors:
///From v-nessa.net
$auth = base64_encode("{$cpuser}:{$cppass}");
$domain = "https://my_domain.com:2083";
$theme = "paper_lantern";
$ftp = false;
$ftp_server = "";
$ftp_username = "";
$ftp_password = "";
$ftp_port = "21";
$ftp_directory = "/";
// Do not change below
$url = $domain . "/frontend/" . $theme . "/backup/dofullbackup.html";
$data = array();
if ($ftp) {
$data["dest"] = "ftp";
$data["server"] = $ftp_server;
$data["user"] = $ftp_username;
$data["pass"] = $ftp_password;
$data["port"] = $ftp_port;
$data["rdir"] = $ftp_directory;
}
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\nAuthorization: Basic $auth\r\n",
'method' => 'POST',
'content' => http_build_query($data)
),
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if (!$result) {
exit("Error backing up server.");
}
} catch (Exception $e) {
echo $e->getMessage();
}
I'm aware that this particular script will fail if the theme is not correct, but from my cPanel I can see that it's still "paper_lantern".
Are there other ways that I might be able to troubleshoot?
Upvotes: 0
Views: 123
Reputation: 87
I'd recommend using the cPanel "UAPI" instead. Here's how you can do a local homedir backup:
$cpuser = "username";
$cppass = "password";
$auth = base64_encode("{$cpuser}:{$cppass}");
$domain = "https://example.com:2083";
$notifyEmail = "[email protected]";
$url = $domain . "/execute/Backup/fullbackup_to_homedir?email=$notifyEmail";
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\nAuthorization: Basic $auth\r\n",
'method' => 'POST'
),
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
print($result);
You can adapt this for FTP or SCP - have a look at the other functions at https://documentation.cpanel.net/display/DD/UAPI+Modules+-+Backup .
Upvotes: 2