Hallo,
In der jetzigen Version werden alle Tabellen in der mySQL DB gesichert. Daher habe ich
die BackupDbRun.php angepasst damit im Backup nur die Tabellen in der Datenbank gesichert werden mit dem definierten Tabellen Prefix (Standard = tl_).
Die Einstellung wird aus der Konfiguration "Datentabellen im Website-Template" übernommen.
Die angehängte Datei von .txt umbenennen in .php und diese in den Ordner system/modules/BackupDB hochladen und die bestehende überschreiben.
Dieser Patch funktioniert mit
Version 3.0.0 stable, Freigabedatum 2012-12-26 Freigegeben für Contao 3.0.0 r1 bis 3.0.1
Code:
//-------------------------
// Backup ausführen
//-------------------------
public function run( )
{
@set_time_limit( 600 );
header( "Pragma: public" );
header( "Expires: 0" );
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
header( "Cache-Control: private", false );
header( "Content-type: application/octet-stream" );
header( "Content-disposition: attachment; filename=Database_".$GLOBALS['TL_CONFIG']['dbDatabase']."_".date( "Y-m-d" )."_".date("His").".sql" );
header( "Content-Transfer-Encoding: binary" );
print $this->BackupDbCommon->getHeaderInfo( true, 'Saved by User : '.$this->User->username.' ('.$this->User->name.')' );
$arrSavedDB = array( 'tl_' ); // Default, Verhalten wie in den Vorversionen von BackupDB
if( isset( $GLOBALS['TL_CONFIG']['backupdb_saveddb'] ) && (trim($GLOBALS['TL_CONFIG']['backupdb_saveddb']) != '') ) {
$arrSavedDB = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['backupdb_saveddb']));
}
//print_r($arrSavedDB);
$arrBlacklist = $this->BackupDbCommon->get_blacklist( );
$sqlarray = $this->BackupDbCommon->getFromDB( );
if( count($sqlarray) == 0 ) print "No tables found in database.";
else {
foreach( array_keys($sqlarray) as $table ) {
$whitelist = false;
// find whitelisted prefix tablename
foreach( array_values($arrSavedDB) as $whitelistprefix ) {
//print_r($whitelistprefix);
if (strpos(strtoupper($table),strtoupper($whitelistprefix)) !== false) {
$whitelist = true;
}
}
if ($whitelist)
{
print $this->BackupDbCommon->get_table_structure( $table, $sqlarray[$table] );
if( in_array( $table, $arrBlacklist ) ) continue; // Blacklisten-Tabellen speichern nur Struktur, keine Daten -> continue
$this->BackupDbCommon->get_table_content( $table ); // Dateninhalte ausgeben
}
}
}
print "\r\n/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\r\n"
."/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\r\n"
."/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;\r\n"
."\r\n# --- End of Backup ---\r\n"; // Endekennung
}
//------------------------------------------------
}
Lesezeichen