Hi,

I've just had the first look at the BACKUP command. Is this proper use?

db_connect($dbuser, $dbpassword, $dbdatabase);

// Lock and flush tables before backup
$query = "LOCK TABLES un_article READ, un_article_writer READ";
$result = mysql_query($query)
 or error(mysql_error());
$query = "FLUSH TABLES";
$result = mysql_query($query)
 or error(mysql_error());

//Perform backup
$query = "BACKUP TABLE un_article, un_article_writer TO 'c:/web/un/backup'";
$result = mysql_query($query) or error(mysql_error());


// Unlock tables
$query = "UNLOCK TABLES";
$result = mysql_query($query)
 or error(mysql_error());

// Present all files with link to download
if ($handle = opendir('/web/un/backup'))
{
 echo "Files:<br>\n";
 while (false !== ($file = readdir($handle)))
 {
   echo "Download $file <a href='backup/$file'>here</a><br>\n";
 }
 closedir($handle);
}

And another question: The created backup files, do they have to be restored to a database with the very same name, or could they be restored to another database?

Are there any differences between backing up this way, and using mysqldump?

And finally: Does mysqldump have a counterpart for use in querystrings like those above?

Best regards,

Anders Thoresson

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to