conocen algun buen script para hacer dump ??
Código PHP:
<?php
//------------------------------------------------------------------------------------------
// Funciones
error_reporting( E_ALL & ~E_NOTICE );
function fetch_table_dump_sql($table, $fp = 0) {
$tabledump = "--\n";
if( !$hay_Zlib )
fwrite($fp, $tabledump);
else
gzwrite($fp, $tabledump);
$tabledump = "-- Table structure for table `$table`\n";
if( !$hay_Zlib )
fwrite($fp, $tabledump);
else
gzwrite($fp, $tabledump);
$tabledump = "--\n\n";
if( !$hay_Zlib )
fwrite($fp, $tabledump);
else
gzwrite($fp, $tabledump);
$tabledump = query_first("SHOW CREATE TABLE $table");
strip_backticks($tabledump['Create Table']);
$tabledump = "DROP TABLE IF EXISTS $table;\n" . $tabledump['Create Table'] . ";\n\n";
if( !$hay_Zlib )
fwrite($fp, $tabledump);
else
gzwrite($fp, $tabledump);
$tabledump = "--\n";
if( !$hay_Zlib )
fwrite($fp, $tabledump);
else
gzwrite($fp, $tabledump);
$tabledump = "-- Dumping data for table `$table`\n";
if( !$hay_Zlib )
fwrite($fp, $tabledump);
else
gzwrite($fp, $tabledump);
$tabledump = "--\n\n";
if( !$hay_Zlib )
fwrite($fp, $tabledump);
else
gzwrite($fp, $tabledump);
$tabledump = "LOCK TABLES $table WRITE;\n";
if( !$hay_Zlib )
fwrite($fp, $tabledump);
else
gzwrite($fp, $tabledump);
$rows = query("SELECT * FROM $table");
$numfields=mysql_num_fields($rows);
while ($row = fetch_array($rows, DBARRAY_NUM)) {
$tabledump = "INSERT INTO $table VALUES(";
$fieldcounter = -1;
$firstfield = 1;
// campos
while (++$fieldcounter < $numfields) {
if( !$firstfield) {
$tabledump .= ', ';
}
else {
$firstfield = 0;
}
if( !isset($row["$fieldcounter"])) {
$tabledump .= 'NULL';
}
else {
$tabledump .= "'" . mysql_escape_string($row["$fieldcounter"]) . "'";
}
}
$tabledump .= ");\n";
if( !$hay_Zlib )
fwrite($fp, $tabledump);
else
gzwrite($fp, $tabledump);
}
free_result($rows);
$tabledump = "UNLOCK TABLES;\n";
if( !$hay_Zlib )
fwrite($fp, $tabledump);
else
gzwrite($fp, $tabledump);
}
function strip_backticks(&$text) {
return $text;
}
function fetch_array($query_id=-1) {
if( $query_id!=-1) {
$query_id=$query_id;
}
$record = mysql_fetch_array($query_id);
return $record;
}
function problemas($msg) {
$errdesc = mysql_error();
$errno = mysql_errno();
$message = "<br>";
$message .= "- Ha habido un problema accediendo a la Base de Datos<br>";
$message .= "- Error $appname: $msg<br>";
$message .= "- Error mysql: $errdesc<br>";
$message .= "- Error número mysql: $errno<br>";
$message .= "- Script: ".getenv("REQUEST_URI")."<br>";
$message .= "- Referer: ".getenv("HTTP_REFERER")."<br>";
echo( "</strong><br><br><hr><center><small>" );
setlocale( LC_TIME,"spanish" );
echo strftime( "%A %d %B %Y - %H:%M:%S", time() );
echo( "<br>©2005 <a href=\"mailto:[email protected]\">Inside PHP</a><br>" );
echo( "vers." . Str_VERS . "<br>" );
echo( "</small></center>" );
echo( "</BODY>" );
echo( "</HTML>" );
die("");
}
function free_result($query_id=-1) {
if( $query_id!=-1) {
$query_id=$query_id;
}
return @mysql_free_result($query_id);
}
function query_first($query_string) {
$res = query($query_string);
$returnarray = fetch_array($res);
free_result($res);
return $returnarray;
}
function query($query_string) {
$query_id = mysql_query($query_string);
if( !$query_id) {
problemas("Invalid SQL: ".$query_string);
}
return $query_id;
}
//------------------------------------------------------------------------------------------
// Main
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<title>Dump y Download la Base de Datos</title>
<!-- no cache headers -->
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="no-cache">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="Cache-Control" content="no-store">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Cache-Control" content="must-revalidate">
<!-- end no cache headers -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</HEAD>
<BODY
bgcolor="#D5D5D5"
text="#000000"
id="all"
leftmargin="25"
topmargin="25"
marginwidth="25"
marginheight="25"
link="#000020"
vlink="#000020"
alink="#000020">
<center><h1>Dump y Download la Base de Datos</h1></center>
<br>
<strong>