1

I've been using the following (partial) code to backup my websites:

 Generated by https://www.ericzhang.me/projects/cpanel-auto-backup/
*/

$auth = base64_encode("{$cpuser}:{$cppass}");
$domain = "{$domain}";
$theme = "paper_lantern";
$ftp = false;
$ftp_server = "";
$ftp_username = "";
$ftp_password = "";
$ftp_port = "21";
$ftp_directory = "/";


$url = $domain . "/frontend/" . $theme . "/backup/dofullbackup.html";
$data = array();
$data['email'] = '';

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 === FALSE) {
  exit("Error backing up server.");
}

Up until about 2 days ago, I wasn't receiving any email notifications (what I want). But now I receive one after any backup. My guess is that cPanel has changed its parameters so that without having some variable which says "no_email=1", that an email is sent. I've tried adding $data['email']="" as well as $data['email']=some_dumb_email_i_never_check@mysite.com but I'm still getting the notifications. Any chance anyone know of an additional variable which I can add to prevent the notifications?

  • What does this email state? Is your script capable of sending emails? You state this is a "cPanel backup", yet you've included a PHP snippet? So this is your own script? Which I guess you are running as a Cron Job? In which case CRON/cPanel might be configured to send an email on success (and/or failure - which is desirable). If the later then no amount of changing your script will change anything. But also, if your script hasn't changed then I would have thought that editing your script is unlikely to make a difference? – DocRoot Mar 1 at 16:00
  • The email has the subject: A full backup of the account “my_account” with the primary domain “my_domain.com” has completed. It then goes on to say "A full backup has completed and is available for download." In addition, it says "This notice is the result of a request made by a computer with the IP address of “my ip” through the “fullbackup” service on the server with an attachment containing a trace of the backup process. And, it is a cPanel backup, but one generated from my script (sorry for the lack of clarity). I definitely haven't configured CRON or cPanel to send an email. – Eric Mar 2 at 17:21
  • My thought is that a new parameter now needs to be added (again I haven't changed this script in years) due to some update with cPanel where I need to specifically say that I don't want to receive an email upon success. – Eric Mar 2 at 17:22
  • I see what you're saying now. From other scripts I've seen, $data['email'] = ''; would probably be sufficient, depending on where you are setting this and how the script is actually being called. Maybe include the entire script in your question, rather than just a snippet (which doesn't really show much). – DocRoot Mar 3 at 17:16
  • I would have thought that would work as well, but I fear it didn't; I've updated my post to include more details of the script. – Eric Mar 3 at 18:00
1

I'm running into the same issue. It looks like the scripts we're using are based upon a deprecated function. The fact that the script is deprecated may be why adding $data["email"] = ""; doesn't work any more.

See https://documentation.cpanel.net/display/DD/cPanel+API+1+Functions+-+Fileman%3A%3Afullbackup for details

Apparently we need to rewrite our scripts using a new function:

https://documentation.cpanel.net/display/DD/UAPI+Functions+-+Backup%3A%3Afullbackup_to_ftp

  • This seems like a reasonable explanation! Are you using the LiveAPI PHP Class? I think that this would be the easiest approach. However, on shared hosting, I'm not convinced that I have access to the Class. – Eric Mar 6 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.