Hey folks, l have this script that backs up my sql database, and tosses it in a tarball.... In any event, the script was working fine yesterday, and now it's not. Any idea's why?
~JSlime
PHP Code:<?php
$dbhost = 'localhost';
$dbuser = 'xxx_myusername';
$dbpass = 'xxx_mypassword';
$dbname = 'xxxx_mydatabase';
$use_gzip = "yes";
$remove_sql_file = "yes";
$remove_gzip_file = "no";
$savepath = "/home/xxx/public_html/xxx";
$send_email = "yes";
$to = "noone@nowhere.com";
$from = "noone@nowhere.com";
$senddate = date("j F Y");
$subject = "MySQL Database Backup - $senddate";
$message = "Your MySQL database has been backed up and is attached to this email";
$use_ftp = "no";
$ftp_server = "localhost";
$ftp_user_name = "ftp_username";
$ftp_user_pass = "ftp_password";
$ftp_path = "/";
$date = date("mdy-hia");
$filename = "$savepath/$dbname-$date.sql";
passthru("mysqldump --opt -h$dbhost -u$dbuser -p$dbpass $dbname >$filename");
if($use_gzip=="yes"){
$zipline = "tar -czf ".$dbname."-".$date."_sql.tar.gz $dbname-$date.sql";
shell_exec($zipline);
}
if($remove_sql_file=="yes"){
exec("rm -r -f $filename");
}
if($use_gzip=="yes"){
$filename2 = "$savepath/".$dbname."-".$date."_sql.tar.gz";
} else {
$filename2 = "$savepath/$dbname-$date.sql";
}
if($send_email == "yes" ){
$fileatt_type = filetype($filename2);
$fileatt_name = "".$dbname."-".$date."_sql.tar.gz";
$headers = "From: $from";
// Read the file to be attached ('rb' = read binary)
$file = fopen($filename2,'rb');
$data = fread($file,filesize($filename2));
fclose($file);
// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" ."Content-Type: multipart/mixed;\n" ." boundary=\"{$mime_boundary}\"";
// Add a multipart boundary above the plain message
$message = "This is a multi-part message in MIME format.\n\n" ."--{$mime_boundary}\n" ."Content-Type: text/plain; charset=\"iso-8859-1\"\n" ."Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
// Add file attachment to the message
$message .= "--{$mime_boundary}\n" ."Content-Type: {$fileatt_type};\n" ." name=\"{$fileatt_name}\"\n" ."Content-Disposition: attachment;\n" ." filename=\"{$fileatt_name}\"\n" ."Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" ."--{$mime_boundary}--\n";
// Send the message
$ok = @mail($to, $subject, $message, $headers);
if ($ok) {
echo "Your message has been sent!\r\n";
} else {
echo "<h4><center>Mail could not be sent. Sorry!</center></h4>";
}
}
if($use_ftp == "yes"){
$ftpconnect = "ncftpput -u $ftp_user_name -p $ftp_user_pass -d debsender_ftplog.log -e dbsender_ftplog2.log -a -E -V $ftp_server $ftp_path $filename2";
shell_exec($ftpconnect);
echo "<h4><center>$filename2 Was created and uploaded to your FTP server!</center>";
}
if($remove_gzip_file=="yes"){
exec("rm -r -f $filename2");
}
?>


LinkBack URL
About LinkBacks



Reply With Quote
Bookmarks