DB Backup on Heart Internet

WordPress database backup plugins do not work on Heart Internet shared hosting due to the setup of the server where loopback for cron jobs is not supported.

Scheduled Jobs

Heart InternetMy preferred method is to use the scheduled jobs feature of the hosting account instead of a backup plugin within WordPress.

Create a new file called dbbackup.php at level above (outside) the public_html directory. Set the file permissions of the script to 711.

Edit the connection and email settings:

 ". $sqlFile;
$createZip = "tar cvzf $attachment $sqlFile";
exec($creatBackup);
exec($createZip);
$headers = array("From"    => $from, "Subject" => $subject);
$textMessage = $attachment;
$htmlMessage = "";
$mime = new Mail_Mime("\n");
$mime->setTxtBody($textMessage);
$mime->setHtmlBody($htmlMessage);
$mime->addAttachment($attachment, "text/plain");
$body = $mime->get();
$hdrs = $mime->headers($headers);
$mail = &Mail::factory("mail");
$mail->send($to, $hdrs, $body);
unlink($sqlFile);
unlink($attachment);
?>

In your web Hosting control panel go into Scheduled Tasks, then in the run this Command field, enter the paths to the PHP interpreter and the backup script separated with a space. It should look similar to:


/usr/bin/php53 /home/sites/mydomain.co.uk/dbbackup.php

Press the Test Command button and check that you receive an email with the database backup attached.

Enter the schedule of when you want the script to run and the email address you want the script message output to go to. Then press the update button.