How do I restore a backup in mysql?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • damezumari

    How do I restore a backup in mysql?

    I successfully take backups of my database with this php code:

    $command = "mysqldump --opt -h$dbhost -u$dbuser -p$dbpass $dbname |
    gzip $backupfile.gz" ;

    $dummy = system($command , $retval);

    But I can not find the code for restoring a backup file. How is it
    done?

    Kind regards,

    Jan Nordgreen
  • sivaji

    #2
    Re: How do I restore a backup in mysql?

    On May 12, 5:22 pm, damezumari <jannordgr...@g mail.comwrote:
    I successfully take backups of my database with this php code:
    >
    $command = "mysqldump --opt -h$dbhost -u$dbuser -p$dbpass $dbname |
    gzip $backupfile.gz" ;
    >
    $dummy = system($command , $retval);
    >
    But I can not find the code for restoring a backup file. How is it
    done?

    just copy the content in that backup file and paste it in mysql
    console thats all.
    or do this
    $mysql -u username -p database < path/to/backup.sql

    you have to do google search before you ask anything in mailing list .

    Comment

    • damezumari

      #3
      Re: How do I restore a backup in mysql?

      I want to restore a .gz file not a .sql file.

      I have tried:

      $command = "mysql -u$dbuser -p$dbpass $dbname < $backupfile.gz" ;
      $dummy = system($command , $retval);

      ($dummy === false) returns false and retval returns 1, but the
      database is not restored.

      What am I doing wrong?

      Kind regards,

      Jan Nordgreen

      Comment

      • Ivan Marsh

        #4
        Re: How do I restore a backup in mysql?

        On Tue, 13 May 2008 08:27:36 -0700, damezumari wrote:
        I want to restore a .gz file not a .sql file.
        >
        I have tried:
        >
        $command = "mysql -u$dbuser -p$dbpass $dbname < $backupfile.gz" ; $dummy
        = system($command , $retval);
        >
        ($dummy === false) returns false and retval returns 1, but the database
        is not restored.
        >
        What am I doing wrong?
        >
        Kind regards,
        The .qz file is a compressed tar file.

        tar xvfz <your file>.gz

        Into a working directory and then perform the restore you with the plain
        text file.

        --
        "Remain calm, we're here to protect you!"

        Comment

        • =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?=

          #5
          Re: How do I restore a backup in mysql?

          damezumari escribió:
          $command = "mysql -u$dbuser -p$dbpass $dbname < $backupfile.gz" ;
          If OS is Unix, try:

          $command = "gunzip --to-stdout $backupfile.gz | mysql -u$dbuser
          -p$dbpass $dbname";



          --
          -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
          -- Mi sitio sobre programación web: http://bits.demogracia.com
          -- Mi web de humor al baño María: http://www.demogracia.com
          --

          Comment

          • damezumari

            #6
            Re: How do I restore a backup in mysql?

            Alvaro, thank you! It worked like a dream. My server is running Linux.

            Kind regards,

            Jan Nordgreen

            Comment

            Working...