<?php
// Visit DigiWire.org For More Cool Scripts Like This
// Feel free to use this script however you like
// For cPanel Use ONLY !!! You must also be able to set cron jobs in your cPanel
// Email address to send the backups to (recommended to be Gmail) However any account with a high limit of space will do.
// ------------------------------------------------------
$email_address = "[email protected]";
// cPanel authentication information: the username and pass you use to logon to cPanel at your host
// ------------------------------------------------------
$cpanel_username = "database_user_name";
$cpanel_password = "database_password";
// The address of your webhost (or the location of the cPanel)
// ------------------------------------------------------
$host = "hostname.com";
// The database to be backed up... NOT INCLUDING THE ACCOUNT NAME BIT...
// For example...
// 'fayte_forums' would become just 'forums'
// 'dave_mydatabase' would become just 'mydatabase'
// ------------------------------------------------------
$database_name = "mydata";
// All Done -> Now upload this file and make sure it can be excuted, set CMOD to 777 if you wish.
// DO NOT edit below this line
function gmail_send_file($email, $from, $file) {
$mime_boundary = "gmail" . md5(uniqid(mt_rand(), 1));
$header = "From: ".$from."\nMIME-Version: 1.0\nContent-Type: multipart/mixed;\n boundary=\"".$mime_boundary."\"\n";
$dateandtime = gmdate("d-m-y @ h:i:s A");
$content = "--".$mime_boundary."\n";
$content .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$content .= "Content-Transfer-Encoding: 7bit\n\n";
$content .= "The database had been backed up and is ready for download below!\n";
$content .= "The backup was excuted at: ".$dateandtime." GMT Time\n\n";
$content .= "--".$mime_boundary."\n";
$content .= "Content-Disposition: attachment;\n";
$content .= "Content-Type: Application/Octet-Stream;";
$content .= " name=\"".basename($file)."\"\n";
$content .= "Content-Transfer-Encoding: base64\n\n";
$content .= chunk_split(base64_encode(file_get_contents($file)))."\n";
$content .= "--".$mime_boundary."\n";
mail($email, "Repricing Ezlx DB backup", $content, $header);
}
gmail_send_file($email_address, "Backup <DBBackup@".$host."", "http://".$cpanel_username.":".$cpanel_password."@".$host.":2082/getsqlbackup/".$database_name.".gz");
?>