BACKUP MYSQL como ?

BACKUP MYSQL como ?

Postby AOKISANTOS » Fri Mar 23, 2007 7:44 pm

Gente como executar e restaurar backup no mysql ?


Alguem poderia fornecer um exemplo de como criar uma rotina para esta finalidade?

Aokisantos
FWH25+XHARBOUR 99.50
AOKISANTOS
 
Posts: 210
Joined: Sun Jul 23, 2006 1:15 am

SOLUCIONADO

Postby AOKISANTOS » Sun Mar 25, 2007 8:02 pm

SOLUCIONADO :D
FWH25+XHARBOUR 99.50
AOKISANTOS
 
Posts: 210
Joined: Sun Jul 23, 2006 1:15 am

Amigo...

Postby leandro » Mon Mar 26, 2007 6:20 am

Me podrias Indicar como lo hiceste...

De antemano Gracias :D
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1484
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: Amigo...

Postby wmormar » Mon Mar 26, 2007 7:16 am

leandro wrote:Me podrias Indicar como lo hiceste...

De antemano Gracias :D


Leandr,

Me corroe la inquietud.

Me gustaria que compartieras tu solución.

gracias de antemano
William, Morales
Saludos

méxico.sureste
User avatar
wmormar
 
Posts: 1074
Joined: Fri Oct 07, 2005 10:41 pm
Location: México

Postby Antonio Linares » Mon Mar 26, 2007 7:23 am

En PHP:
Code: Select all  Expand view
<?php

//Copyright (C) 2000-2006  Antonio Grandío Botella http://www.antoniograndio.com
//Copyright (C) 2000-2006  Inmaculada Echarri San Adrián http://www.inmaecharri.com

//This file is part of Catwin.

//CatWin is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2 of the License, or
//(at your option) any later version.

//CatWin is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details:
//http://www.gnu.org/copyleft/gpl.html

//You should have received a copy of the GNU General Public License
//along with Catwin Net; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

if (!is_dir("_backups")) {mkdir("_backups");}

deldir("_backups");

$fich = $_SESSION['empresa']."---".date('Y-m-d-His').".sql";

if( !@function_exists('gzopen')) {
   $gz = false;
   $f = fopen( "_backups/".$fich, 'w' );
}
else {
   $fich = $fich . ".gz";
   $gz = true;
   $f = gzopen( "_backups/".$fich, 'w6' );
}

$db = mysql_select_db($_SESSION['empresa']);

$escribir = "-- Base de datos: ".$_SESSION['empresa']." - Fecha: " . strftime( "%d/%m/%Y - %H:%M:%S", time() )."\n";
escribir($f, $gz, $escribir);

$result = mysql_query( 'SHOW tables' );
while( $fila = mysql_fetch_array($result) ) {
   if ($_SESSION['empresa'] == "nuevocat" AND $fila[0] == "referers") {continue;}
   escribetabla( $fila[0], $f, $gz);
   escribir($f, $gz, "\n");
}

if( !$gz ){
   fclose($f);
   } else {
   gzclose($f);
}

echo "<a href='_backups/$fich'>Bajar la copia de seguridad <span class='b'>$fich</span></a>";

function escribetabla($table, $f = 0, $gz) {
   $escribir = "\n-- Tabla `$table`\n";
   escribir($f, $gz, "\n");
   escribir($f, $gz, $escribir);
   $escribir = mysql_fetch_array(mysql_query("SHOW CREATE TABLE $table"));
   quitar($escribir['Create Table']);
   $escribir = "DROP TABLE IF EXISTS $table;\n" . $escribir['Create Table'] . ";\n\n";
   escribir($f, $gz, $escribir);
   $escribir = "--\n";
   escribir($f, $gz, $escribir);
   $escribir = "-- Dumping `$table`\n";
   escribir($f, $gz, $escribir);
   $escribir = "--\n\n";
   escribir($f, $gz, $escribir);
   $escribir = "LOCK TABLES $table WRITE;\n";
   escribir($f, $gz, $escribir);

   $result = mysql_query("SELECT * FROM $table");
   $campos=mysql_num_fields($result);
   while ($fila = mysql_fetch_array($result)) {
      $escribir = "INSERT INTO $table VALUES(";
      escribir($f, $gz, $escribir);
      $n = 0;
      while ($n < $campos) {
         $escribir = "";
         if ($n) {$escribir = ", ";}
         if( !isset($fila["$n"])) {$escribir .= 'NULL';} else {$escribir .= "'" . mysql_escape_string($fila["$n"]) . "'";}
         escribir($f, $gz, $escribir);
         $n = $n+1;
      }
      $escribir = ");\n";
      escribir($f, $gz, $escribir);
   }
   $escribir = "UNLOCK TABLES;";
   escribir($f, $gz, $escribir);
}

function quitar(&$text) {
   return $text;
}

function escribir($f, $gz, $escribir) {
   if( !$gz ){
      fwrite( $f, $escribir );
   } else {
      gzwrite( $f, $escribir );   
   }
}

function deldir($dir){
   $current_dir = opendir($dir);
   while($entryname = readdir($current_dir)){
      if(is_dir("$dir/$entryname") and ($entryname != "." and $entryname!="..")){
          deldir("${dir}/${entryname}");
         }elseif($entryname != "." and $entryname!=".."){
         unlink("${dir}/${entryname}");
      }
   }
   closedir($current_dir);
}

?>
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

solução

Postby AOKISANTOS » Tue Mar 27, 2007 11:43 am

FWH25+XHARBOUR 99.50
AOKISANTOS
 
Posts: 210
Joined: Sun Jul 23, 2006 1:15 am

Postby Willi Quintana » Tue Apr 03, 2007 6:18 pm

Holas, si se le asigna la usuario el priviliegio >"files", se puede usar la siguiente orden

"SELECT * INTO OUTFILE '/BACKS/listado.txt' FROM listado"

donde listado.txt contendra la infoirmacion de la tabla listado en formato txt plano...

Salu2
User avatar
Willi Quintana
 
Posts: 1002
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 33 guests