"; $sendfrom = "Automated Backup "; $sendsubject = "Daily Mysql Backup"; $bodyofemail = "Here is the daily backup."; // don't need to edit below this section $filearray = array(); $backupzip = $dbfile . "_" . date("Y-m-d") . ".tar.gz"; $tarcommand = "tar -czvf $backupzip "; //create a file name for each db, dump the database and append the db file to the tar command foreach ($dbarray as $i => $value) { $filearray[$i] = $dbnames[$i] . "_" . date("Y-m-d") . '.sql'; $tarcommand .= $filearray[$i] . " "; system("mysqldump -h $dbhost -u $dbuser -p$dbpass $dbnames[$i] > $filearray[$i]"); } // create the tar.gz file system($tarcommand); // Mail the file include('Mail.php'); include('Mail/mime.php'); $message = new Mail_mime(); $text = "$bodyofemail"; $message->setTXTBody($text); $message->AddAttachment($backupzip); $body = $message->get(); $extraheaders = array("From"=>"$sendfrom", "Subject"=>"$sendsubject"); $headers = $message->headers($extraheaders); $mail = Mail::factory("mail"); $mail->send("$sendto", $headers, $body); // Delete the files from your server foreach ($filearray as $i => $value) { unlink($filearray[$i]); } unlink($backupzip); ?>