Hello there,
I need to do a DB dump for a website, but its using code I’m not familiar with can anyone help?
Here is the connection information:
require_once 'DB/DataObject.php'; <<-- cant see this file
$options = &PEAR::getStaticProperty('DB_DataObject','options');
$options = array(
'database' => 'mysql://MYWEBSITE_web:manse1802@localhost/MYWEBSITE_web',
'schema_location' => '/home/MYWEBSITE/DataObjects',
'class_location' => '/home/MYWEBSITE/DataObjects',
'require_prefix' => 'DataObjects/',
'class_prefix' => 'DataObjects_',
);
Now obviously not being completely useless I normally use this script to to a DB and email it to me, but in this case I just get a bank file. The lack of a password could the problem?
// mysql & minor details..
$tmpDir = "/tmp/";
$user = "manse1802";
$password = "";
$dbName = "MYWEBSITE_web";
$prefix = "DataObjects_";
// email settings...
$to = "me@xxx.com";
$from = "noreply@xxx.com";
$subject = "db - backup";
$sqlFile = $tmpDir.$prefix.date('Y_m_d').".sql";
$attachment = $tmpDir.$prefix.date('Y_m_d').".tgz";
$creatBackup = "mysqldump -u ".$user." --password=".$password." ".$dbName." > ".$sqlFile;
$createZip = "tar cvzf $attachment $sqlFile";
exec($creatBackup);
exec($createZip);
$headers = array('From' => $from, 'Subject' => $subject);
$textMessage = $attachment;
$htmlMessage = "";
$mime = new Mail_Mime("\
");
$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);