News:

Wondering if this will always be free?  See why free is better.

Main Menu

Major problem.. need help

Started by LW, June 01, 2005, 01:21:45 AM

Previous topic - Next topic

LW

OK, I know this site doesn't offer support for YaBBSE but I've got a big problem... Hackers crashed my hard drive on my dedicated server. I have a backup of the database from Arpil 28 that I want to reinstall. I also figured once I got it installed, this would be a good time to upgrade to SMF.

However, the problem I'm having is that the script to restore the database is not working. It just doesn't do anything. I have no idea if this has anything to do with the version of MySQL on the new hard drive is newer than what I was using before. Also, the script I'm trying to use is from 2002 (I think).

Am I screwed?

[Unknown]

What script are using using?  What does your database backup look like, and how big is it?

-[Unknown]

LW

The database is huge... 125 megs...

Here's the script...

Quote<?php

// Author:   Dave Smulders
//           The main script is done by Dave Smulders.
// Modified: Andrea Hubacher
//           05. Apr 2002 - suppress non-error messages,
//           05. Apr 2002 - show query command line in eror messages
//           05. Apr 2002 - show summary at the end of the script (total number of queries and errors)

// This section needs to be adapted to your needs. Enter database information and name of dump sql file here.
// Rename the script file extension from .txt to .php and upload the php script and the dump file into the same directory.
// Then run the php restore script with your browser.

  $db_name = "*****";         // replace ***** by your database name
  $db_user = "*****";         // replace ***** by your database user
  $db_passwd = "*****";      // replace ***** by your database password
  $db_server = "localhost";   // can usually be left
  $db_prefix = "";            // can be left empty
 
  $sql_file = "backup.sql";   // replace by the name of your dump file

// From here on the script usually does not to be changed any more.

// Print Header
print <<<EOT
<html>
<head>
  <title>Restore MySQL Dump</title>
</head>
<body>
<h1>Restore MySQL Dump</h1><br>
EOT;

// Main Script starts here

  //connect to database
  $db = mysql_connect($db_server, $db_user, $db_passwd);
  //select database
  mysql_select_db($db_name, $db);
 
      set_time_limit(10000);
      $fd = fopen ($sql_file, "r");

      $query = "";
      $counter = 0;
   $counterrs = 0;
      while (!feof ($fd)) {
        $line = fgets($fd, 4096);
        $line = chop($line);

        if(!ereg("^#",$line)) $query .= $line;
        if((ereg(";\n?$",$line) or feof($fd)) and $query != "") {
            $counter++;
            if (!mysql_query($query))
              {
              echo "<i>Executing query $counter</i><br>";
              print "<i>Error: ".mysql_error()."</i><br>";
              print "<i>Query that could not be executed: <br>";
              print $query; print "</i><br><br>\n";
              $counterrrs++;
              }
            else
              {
              // do not display non-errors
              // echo "<i>Executing query $counter</i><br>";
              // print "<i>No Errors</i><br><br>\n";
              };
            $query = "";
        }
      }
      fclose ($fd);

// Print Summary
echo "Number of queries executed: ".$counter."<br>";
echo "Number of errors encountered: ".$counterrrs."<br>";

// Print html footer
print <<<EOT
</body>
</html>
EOT;


?>

[Unknown]


LW

THANK YOU.. worked like a charm... now off to upgrade.

LW

Upgrade went off without a hitch... It was very easy and I was suprised it went through without any errors with a forum as large as mine.

Only problem I've had so far is when I sent out a e-mail to all members (about 4,200) it gave me a "too many connections" mysql error. It seems all the e-mails went through, but I had to restart the server to get it going again.

[Unknown]

You may wish to ask your host to increase the max_connections in my.cnf.

-[Unknown]

LW

I've increased max connections in the past, but then it just simply freezes mysql and doesn't give error messages any more. Here's to hoping it doesn't happen very often...

Advertisement: