SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict thoresson's Avatar
    Join Date
    Dec 2002
    Location
    Gothenburg, Sweden
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    is this proper use of BACKUP command?

    Hi,

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

    PHP Code:
     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?

  2. #2
    SitePoint Member
    Join Date
    Nov 2003
    Location
    iran
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And how Restore?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •