Seite 1 von 1

Backup Modul

Verfasst: Mi 3. Dez 2003, 17:45
von Snoopy
Das Tool MySQLCommander (www.bitesser.de) eignet sich hervorragend für das Backup
von Contenido. Ich habe nun ein Modul geschrieben, dass die URL interface Funktion
von MySQLCommander nutzt.

Benötigt wird MySQLCommander auf dem Webserver. Es muss dort über die Admin Funktion
ein User unter "Configuration for URL interface" eingetragen werden. Dieser wird dann in
meinem Modul abgefragt.

Der Pfad zu MySQLCommander muss für die include Funktion des Moduls in der datei
root\contenido\includes\config.php eingetragen werden.
(Tipp für alle die probleme beim includen von PHP-Code haben)

Code: Alles auswählen

--------Auszug aus Config.php----------------

$cfg['path']['backup']  	= 'C:/Programme/Apache Group/Apache2/htdocs/mysqlcommander/interface/';
$cfg['path']['backup_html']     = 'http://127.0.0.1/mysqlcommander/interface/';

--------Auszug ENDE--------------------------
Die Pfade sind natürlich anzupassen !!!!!!!


Das Modul OUTPUT:

Code: Alles auswählen

<!***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname   :     Backup
* Author(s)   :     Peter Beauvain
* Copyright   :     None
* Created     :     01-12-2003
* Modified    :     03-12-2003
************************************************!>


<?
$meineseite=$auth->url();

if ($a == "") { $a = "add"; }

if ($a == "add") {

  
echo "<br>";
  echo "<FORM  name='gb' id='gb' action=".$auth->url()." method='post' enctype='application/x-www-form-urlencoded'>"; 
  echo "<INPUT  TYPE=hidden  NAME=a  VALUE=send>"; 
  echo "<input type=hidden name=required value=name,comments>";
  echo "<table border=0 cellpadding=4 cellspacing=0 width=490 >
<tr><td class=p1 align=right>
GZIP akivieren:</td>
<td class=p1><input type=radio name=gzip checked value=1> Ja 
<input type=radio name=gzip value=0> Nein
</td></tr>          

<tr><td class=p1 align=right>
Überschreiben:</td>
<td class=p1><input type=radio name=over checked value=1> Ja 
<input type=radio name=over value=0> Nein
</td></tr>

<tr><td class=p1 align=right>
Versionisierung:</td>
<td class=p1><input type=radio name=vers value=1> Ja 
<input type=radio name=vers checked value=0> Nein
</td></tr>

<tr><td class=p1 align=right ID=fontCMS_VALUE[1] width=30%><B> DB-User:  </b></td><td><INPUT class=tr12 ID=fontCMS_VALUE[2] TYPE=text NAME=name style=width:70%;></td></tr>
          <tr><td class=p1  align=right ID=fontCMS_VALUE[1] width=30%> DB-Passwort:  </td><td><INPUT class=tr12 ID=fontCMS_VALUE[2] TYPE=password NAME=pass style=width:70%;></td></tr><tr>
          <tr><td TD class=p1 align=right ID=fontCMS_VALUE[1] width=30%> DB-Name:  </td><td><INPUT class=tr12 ID=fontCMS_VALUE[2] TYPE=text NAME=dbname style=width:70%;></td></tr>
          
          <tr><td class=p1 align=right ID=fontCMS_VALUE[1] width=30%><br><a href=# onClick=gb.submit();>Starte Backup  </a></td></tr>
        </table>";
} 

 
    
if($name!=""&&$pass!=""&&$dbname!="")
require($cfg['path']['backup_html']."backup1.php?username=$name&password=$pass&database=$dbname&tables=all_tables&gzipping=$gzip&versioning=$vers&test=1&overwrite=$over");

else{
if($a == "send")
echo "<br><p><font class=textbold><b>   Versuchen Sie es bitte nochmal !</b><br>Die Felder für DB-User,&nbsp;DB-Passwort&nbsp;und DB-Name müssen ausgefüllt werden.</p>"; 
}

?>
Der folgende Code muss als backup1.php in folgendem Ordner gespeichert werden:

Server root\mysqlcommander\interface\

Die Backup Dateien werden unter Server root\mysqlcommander\interface\data\
gespeichert. Demzufolge muss dieser Ordner über Schreibrechte verfügen.


Datei backup1.php:

Code: Alles auswählen

  <style type="text/css">
.admin .title {
	background-color : #587698;
	color : White;
	font-family: arial,verdana, geneva, sans-serif;
	text-align : center;
	border-bottom : 1px solid Black;
	padding : 3px;
}

.line_color0 {
	background-color: #E1E1E1;
	color: #000000;
	display: block;
	border : 1px solid Black;
	padding-left: 5px;
	padding-top: 3px;
	padding-bottom: 3px;
	width: 100%;
}

.line_color1 {
	background-color: White;
	display: block;
	border-left : 1px solid Black;
	border-right : 1px solid Black;
	padding-left: 5px;
	padding-top: 3px;
	padding-bottom: 3px;
	color: #000000;
	width: 100%;
}
.input_box {
	font-family: Arial,Verdana, Geneva, Helvetica, sans-serif;
	font-size: 11px;
	border : 1px solid Black;
	background-color : #587698;
	color : Black;
	
}
</style>
	</head>
	<body>
	<br>
	<br>
	
	<table width="520px" border="0" cellspacing="0" cellpadding="5">
	<tr>
<?php
/**
* HTTP interface for MySQL Commander to backup tables via an URL Call
* not possible to backup with bigtable and emailing option
*
* parameters are
* - username : username for the interface. defined in configuration
* - password : password for the interface. defined in configuration
* - database : name of the database to backup
* - tables : string of all tables for backup. seperated by |. if the value is 'all_tables' all tables in the given database will be backupped.
* - gzipping : can be 1 or 0 for gzip or not
* - versioning : can be 1 or 0 for for versioning on or off. if versioning the files will be stored in a subfolder named with the acatual date and actual timme is added to all filenames.
* - overwrite : can be 1 or 0 for overwriting existing files or not
* - seperator : string of the seprator for tablefields. default : ||#||
*
* Sample URL call: backup.php?username=test&password=test2&database=mysql&tables=db|user&gzipping=0&versioning=1&seperator=||#||
*
*/

$home="../";
$blnLoginCheck = false;
include $home."ressourcen/config.php";
include $home."ressourcen/dbopen.php";

header("Content-type: text/plain");
$strResult = "";
if (isset($config->interface_username) AND (trim($config->interface_username) != "") AND isset($config->interface_password) AND (trim($config->interface_password) != "")) {

	if ( isset($_GET['username']) AND ($_GET['username'] == $config->interface_username) AND isset($_GET['password']) AND ($_GET['password'] == $config->interface_password) ) {
  if ( isset($_GET['database']) AND isset($_GET['tables']) ) {
  
  	if (trim($_GET['tables']) == "all_tables") {
    $tables = $funcs->get_tables($_GET['database']);
  	} else {
    $tables = explode("|", $_GET['tables']);
  	}
  	if (!isset($_GET['seperator'])) $seperator = "||#||";
  	else $seperator = $_GET['seperator'];
  	if (isset($_GET['gzipping']) AND $_GET['gzipping'] ) $gzipping = "yes";
  	else $gzipping = "no";
  	if (isset($_GET['overwrite']) AND $_GET['overwrite'] ) $overwrite = "yes";
  	else $overwrite = "no";
  	if (isset($_GET['versioning']) AND $_GET['versioning'] ) $blnVersioning = true;
  	else $blnVersioning = false;
    	
  	for ($i=0; $i<count($tables); $i++) {
    if (trim($tables[$i]) != "") {
    	$res = $funcs->backup_def($_GET['database'], $tables[$i], $overwrite, "./", $blnVersioning);
    	if (!isset($res['error'])) $strResult .= "<span class=\"line_color0\">"."Definition: DB: "."<strong>".$_GET['database'] . ", table: ".$tables[$i] ."</strong>". ", success: " . $res['success']."<br></span>";
    	else $strResult .= "<span class=\"line_color0\">"."Definition: DB: ".$_GET['database'] . ", table: ".$tables[$i] . ", success: " . $res['success'].", message: " . $res['error']."<br></span>";
    	$result_con = $funcs->backup_content($_GET['database'], $tables[$i], $seperator, $overwrite, $gzipping, "yes", "./", $blnVersioning);
    	//print_r($result_con);
    	if (isset($result_con['result']) ) $strResult .= "<span class=\"line_color1\">"."Data: DB: "."<strong>".$_GET['database'] . ", table: ".$tables[$i] ."</strong>". ", success: " . $result_con['success'].", result: " . $result_con['result']."<br></span>";
    	else $strResult .= "<span class=\"line_color1\">"."Data: DB: "."<strong>".$_GET['database'] . ", table: ".$tables[$i] ."</strong>". ", success: " . $result_con['success'].", message: " . $result_con['error']."<br></span>";
    } else $strResult .= "tablename " . ($i+1) . " was empty!\n";
  	}
  }
	} else $strResult .= "<span class=\"line_color0\">"."given username and/or password incorrect!\n"."<br></span>";
}  else $strResult .= "<span class=\"line_color0\">"."username and/or password for interface access not defined!\n"."<br></span>";
echo "<td class=\"input_box\">$strResult";
echo"</td>";
echo"</tr>";
?>
</table>
<br><br>
</body>
Ach ja das Modul benutzt zwei styles, die in die format.css eingfügt werden können oder im Modul an eure format css anpassen:


Viel Spass mit den Backups euer Snoopy ;)

Code: Alles auswählen

.tr12 {
	background: #FFFFFF;
	border-bottom: #000000 1px solid;
	border-left: #C9C9C9 1px solid;
	border-right: #000000 1px solid;
	border-top: #C9C9C9 1px solid;
}
.p1 {
	color: #000000;
	font-family: helvetica, arial, geneva, sans-serif;
	font-size: 11px;
	font-weight: bold;
}

Verfasst: Mo 16. Feb 2004, 14:20
von alessandro
Hi,
- ich habe das modul backup kreirt (das output)
-dann habe ich ein template dass diese Modul enthält
-ich habe eine Seite die diese template enthält.
-ich habe das File backup1.php unter /mysqlcommander/interface kreirt.
-ich habe das config geändert

aber wenn ich diese Seite rufe kommt nicht...

Wovon kann ich den backup starten?

Danke für die Hilfe.

Bye.

Alessandro