Struggeling with relocating
Dieser Commit ist enthalten in:
Commit
89ea01c429
301 geänderte Dateien mit 59926 neuen und 0 gelöschten Zeilen
70
inc/dump/do_dump.php
Normale Datei
70
inc/dump/do_dump.php
Normale Datei
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @version SVN: $rev: 1207 $
|
||||
* @author $Author$
|
||||
* @lastmodified $Date$
|
||||
*/
|
||||
|
||||
// first call of a new backup progress -> set start values
|
||||
$dump = $_SESSION['dump'];
|
||||
$dump['tables_total'] = 0;
|
||||
$dump['records_total'] = 0;
|
||||
$dump['tables_optimized'] = 0;
|
||||
$dump['part'] = 1;
|
||||
$dump['part_offset'] = 0;
|
||||
$dump['errors'] = 0;
|
||||
//-1 instead of 0 is needed for the execution of command before backup
|
||||
$dump['table_offset'] = -1;
|
||||
$dump['table_record_offset'] = 0;
|
||||
$dump['filename_stamp'] = '';
|
||||
$dump['speed'] = $config['minspeed'] > 0 ? $config['minspeed'] : 50;
|
||||
$dump['max_zeit'] =
|
||||
(int) $config['max_execution_time'] * $config['time_buffer'];
|
||||
$dump['dump_start_time'] = time();
|
||||
$dump['countdata'] = 0;
|
||||
$dump['table_offset_total'] = 0;
|
||||
$dump['page_refreshs'] = 0;
|
||||
// used as overall flag including e-mail and ftp-actions
|
||||
$dump['backup_in_progress'] = 1;
|
||||
// used to determine id databases still need to be dumped
|
||||
$dump['backup_done'] = 0;
|
||||
$dump['selected_tables'] = FALSE;
|
||||
if (isset($_POST['sel_tbl'])) {
|
||||
$dump['selected_tables'] = $_POST['sel_tbl'];
|
||||
}
|
||||
// function was called in dump_prepare
|
||||
// -- maybe get rid of this second call later on
|
||||
prepareDumpProcess();
|
||||
// last_db_actual is used to detect if db changed in multidump-mode
|
||||
// -> set to first db
|
||||
$dump['last_db_actual'] = $dump['db_actual'];
|
||||
|
||||
$_SESSION['config_file'] = $config['config_file'];
|
||||
$_SESSION['dump'] = $dump;
|
||||
|
||||
$tplDoDump = new MSDTemplate();
|
||||
$tplDoDump->set_filenames(array('tplDoDump' => 'tpl/dump/dump.tpl'));
|
||||
$gzip = $config['compression'] == 1 ? $icon['gz'] : $lang['L_NOT_ACTIVATED'];
|
||||
$tplDoDump->assign_vars(
|
||||
array(
|
||||
'ICONPATH' => $config['files']['iconpath'],
|
||||
'GZIP' => $gzip,
|
||||
'SESSION_ID' => session_id(),
|
||||
'NOTIFICATION_POSITION' => $config['notification_position']
|
||||
)
|
||||
);
|
||||
|
||||
$sizeUnits = array(1, 1024, 1024 * 1024, 1024 * 10242 * 1024);
|
||||
$size = $config['multipartgroesse1'] * $sizeUnits[$config['multipartgroesse2']];
|
||||
if ($config['multi_part'] > 0) {
|
||||
$tplDoDump->assign_block_vars(
|
||||
'MULTIPART', array('SIZE' => byteOutput($size))
|
||||
);
|
||||
}
|
||||
|
||||
$tplDoDump->assign_var('TABLES_TO_DUMP', $dump['tables_total']);
|
||||
|
||||
88
inc/dump/dump_finished.php
Normale Datei
88
inc/dump/dump_finished.php
Normale Datei
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @version SVN: $rev: 1207 $
|
||||
* @author $Author$
|
||||
* @lastmodified $Date$
|
||||
*/
|
||||
|
||||
if (!defined('MSD_VERSION')) die('No direct access.');
|
||||
include ('./inc/define_icons.php');
|
||||
$dump = $_SESSION['dump'];
|
||||
|
||||
$tplDumpFinished = new MSDTemplate();
|
||||
$tplDumpFinished->set_filenames(
|
||||
array('tplDumpFinished' => 'tpl/dump/dump_finished.tpl')
|
||||
);
|
||||
$recordsTotal = String::formatNumber((int)$dump['records_total']);
|
||||
$tablesTotal = $dump['tables_total'];
|
||||
$msg = sprintf($lang['L_DUMP_ENDERGEBNIS'], $tablesTotal, $recordsTotal);
|
||||
$tplDumpFinished->assign_vars(
|
||||
array(
|
||||
'ICON_OPEN_FILE' => $icon['small']['open_file'],
|
||||
'ICON_EDIT' => $icon['small']['edit'],
|
||||
'ICON_VIEW' => $icon['small']['view'],
|
||||
'SESSION_ID' => session_id(),
|
||||
'BACKUPPATH' => $config['paths']['backup'],
|
||||
'PAGE_REFRESHS' => $dump['page_refreshs'],
|
||||
'TIME_ELAPSED' => getTimeFormat(time() - $dump['dump_start_time']),
|
||||
'MSG' => $msg
|
||||
)
|
||||
);
|
||||
|
||||
if (count($dump['databases']) > 1) {
|
||||
$msg = sprintf($lang['L_MULTIDUMP_FINISHED'], count($dump['databases']));
|
||||
$tplDumpFinished->assign_block_vars('MULTIDUMP', array('MSG' => $msg));
|
||||
}
|
||||
$i = 1;
|
||||
foreach ($_SESSION['log']['files_created'] as $file) {
|
||||
$fileSize = @filesize($config['paths']['backup'] . $file);
|
||||
$tplDumpFinished->assign_block_vars(
|
||||
'FILE',
|
||||
array(
|
||||
'NR' => $i,
|
||||
'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1',
|
||||
'FILENAME' => $file,
|
||||
'FILENAME_URLENCODED' => urlencode($file),
|
||||
'FILESIZE' => byteOutput($fileSize)
|
||||
)
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
|
||||
$i = 1;
|
||||
foreach ($_SESSION['log']['actions'] as $message) {
|
||||
$timestamp = substr($message, 0, 19);
|
||||
$message = substr($message, 20);
|
||||
$tplDumpFinished->assign_block_vars(
|
||||
'ACTION',
|
||||
array(
|
||||
'NR' => $i,
|
||||
'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1',
|
||||
'TIMESTAMP' => $timestamp,
|
||||
'ACTION' => $message
|
||||
)
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (sizeof($_SESSION['log']['errors']) > 0) {
|
||||
$tplDumpFinished->assign_block_vars('ERROR', array());
|
||||
$i = 1;
|
||||
foreach ($_SESSION['log']['errors'] as $error) {
|
||||
$timestamp = substr($error, 0, 19);
|
||||
$error = substr($error, 20);
|
||||
$tplDumpFinished->assign_block_vars(
|
||||
'ERROR.ERRORMSG',
|
||||
array(
|
||||
'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1',
|
||||
'TIMESTAMP' => $timestamp,
|
||||
'MSG' => $error
|
||||
)
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
158
inc/dump/dump_prepare.php
Normale Datei
158
inc/dump/dump_prepare.php
Normale Datei
|
|
@ -0,0 +1,158 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @version SVN: $rev: 1207 $
|
||||
* @author $Author$
|
||||
* @lastmodified $Date$
|
||||
*/
|
||||
|
||||
if (!defined('MSD_VERSION')) die('No direct access.');
|
||||
// remove table selection from previous runs
|
||||
if (isset($dump['sel_tbl'])) {
|
||||
unset($dump['sel_tbl']);
|
||||
}
|
||||
if (isset($_SESSION['dump']['sel_tbl'])) {
|
||||
unset($_SESSION['dump']['sel_tbl']);
|
||||
}
|
||||
//if we are not in mode expert -> reset hidden settings to safe defaults
|
||||
if ($config['msd_mode'] == 0) {
|
||||
$config['replace_command'] = 0;
|
||||
}
|
||||
|
||||
$tplDumpPrepare = new MSDTemplate();
|
||||
$tplDumpPrepare->set_filenames(
|
||||
array('tplDumpPrepare' => 'tpl/dump/dump_prepare.tpl')
|
||||
);
|
||||
if ($config['msd_mode'] > 0) {
|
||||
$tplDumpPrepare->assign_block_vars('MODE_EXPERT', array());
|
||||
}
|
||||
// set charset-selectbox to standard-encoding of MySQL-Server as initial value
|
||||
$dump['sel_dump_encoding'] = 'utf8';
|
||||
$dump['dump_encoding'] = 'utf8';
|
||||
$charsets=$dbo->getCharsets();
|
||||
foreach ($charsets as $name=>$val) {
|
||||
$charsetsDescription[$name]=$name.' - '.$val['Description'];
|
||||
}
|
||||
// tables will be selected on next page, but we need a dummy val
|
||||
// for prepareDumpProcess()
|
||||
$dump['selected_tables'] = false;
|
||||
$dbsToBackup = array();
|
||||
// look up which databases need to be dumped
|
||||
prepareDumpProcess();
|
||||
$dbs = array_keys($dump['databases']);
|
||||
$dbsToBackup = implode(', ', $dbs);
|
||||
|
||||
$cext = ($config['cron_extender'] == 0) ? 'pl' : 'cgi';
|
||||
$scriptName = $_SERVER['SCRIPT_NAME'];
|
||||
$serverName = $_SERVER['SERVER_NAME'];
|
||||
$url = substr($scriptName, 0, strrpos($scriptName, '/') + 1);
|
||||
if (substr($url, -1) != '/') $url .= '/';
|
||||
if (substr($url, 0, 1) != '/') $url = '/' . $url;
|
||||
$refdir = (substr($config['cron_execution_path'], 0, 1) == '/') ? '' : $url;
|
||||
$scriptdir = $config['cron_execution_path'] . 'crondump.' . $cext;
|
||||
$perlModultest = $config['cron_execution_path'] . "perltest.$cext";
|
||||
$perlSimpletest = $config['cron_execution_path'] . "simpletest.$cext";
|
||||
$scriptentry = myRealpath('./') . $config['paths']['config'];
|
||||
$cronabsolute = myRealpath('./') . $scriptdir;
|
||||
if (substr($config['cron_execution_path'], 0, 1) == '/') {
|
||||
$cronabsolute = $_SERVER['DOCUMENT_ROOT'] . $scriptdir;
|
||||
}
|
||||
$confabsolute = $config['config_file'];
|
||||
$perlHttpCall = getServerProtocol() . $serverName . $refdir;
|
||||
$perlHttpCall .= $config['cron_execution_path'] . 'crondump.' . $cext;
|
||||
$perlHttpCall .= '?config=' . $confabsolute;
|
||||
$perlCrontabCall = 'perl ' . $cronabsolute . ' -config=' . $confabsolute;
|
||||
$perlCrontabCall .= ' -html_output=0';
|
||||
$tplDumpPrepare->assign_vars(
|
||||
array(
|
||||
'SESSION_ID' => session_id(),
|
||||
'CONFIG_FILE' => $config['config_file'],
|
||||
'POSSIBLE_DUMP_ENCODINGS' =>
|
||||
Html::getOptionlist($charsetsDescription, 'utf8'),
|
||||
'DBS_TO_BACKUP' => $dbsToBackup,
|
||||
'TABLES_TOTAL' => $dump['tables_total'],
|
||||
'RECORDS_TOTAL' => String::formatNumber(intval($dump['records_total'])),
|
||||
'DATASIZE_TOTAL' => byteOutput($dump['datasize_total']),
|
||||
'NR_OF_DBS' => count($dump['databases']),
|
||||
'DUMP_COMMENT' => Html::replaceQuotes($dump['comment']),
|
||||
'PERL_TEST' => $perlSimpletest,
|
||||
'PERL_MODULTEST' => $perlModultest,
|
||||
'PERL_HTTP_CALL' => $perlHttpCall,
|
||||
'PERL_CRONTAB_CALL' => $perlCrontabCall,
|
||||
'PERL_ABSOLUTE_PATH_OF_CONFIGDIR' => $scriptentry,
|
||||
'TIMESTAMP' => time()
|
||||
)
|
||||
);
|
||||
|
||||
if (count($dump['databases']) == 1 && $config['db_actual'] == $dbsToBackup) {
|
||||
$tplDumpPrepare->assign_block_vars('TABLESELECT', array());
|
||||
}
|
||||
if ($config['compression'] == 1) {
|
||||
$tplDumpPrepare->assign_block_vars('GZIP_ACTIVATED', array());
|
||||
} else {
|
||||
$tplDumpPrepare->assign_block_vars('GZIP_NOT_ACTIVATED', array());
|
||||
}
|
||||
|
||||
if ($config['multi_part'] == 1) {
|
||||
$tplDumpPrepare->assign_block_vars(
|
||||
'MULTIPART',
|
||||
array('SIZE' => byteOutput($config['multipart_groesse']))
|
||||
);
|
||||
} else {
|
||||
$tplDumpPrepare->assign_block_vars('NO_MULTIPART', array());
|
||||
}
|
||||
|
||||
if ($config['send_mail'] == 1) {
|
||||
$tplDumpPrepare->assign_block_vars(
|
||||
'SEND_MAIL',
|
||||
array('RECIPIENT' => $config['email']['recipient_address'])
|
||||
);
|
||||
$recipients = $config['email']['recipient_cc'];
|
||||
$recipientsCc = implodeSubarray($recipients, 'address');
|
||||
if ($recipientsCc > '') {
|
||||
$tplDumpPrepare->assign_block_vars(
|
||||
'SEND_MAIL.CC', array('EMAIL_ADRESS' => $recipientsCc)
|
||||
);
|
||||
}
|
||||
if ($config['email']['attach_backup'] == 1) {
|
||||
$bytes = $config['email_maxsize1'] * 1024;
|
||||
if ($config['email_maxsize2'] == 2) {
|
||||
$bytes = $bytes * 1024;
|
||||
}
|
||||
$tplDumpPrepare->assign_block_vars(
|
||||
'SEND_MAIL.ATTACH_BACKUP', array('SIZE' => byteOutput($bytes))
|
||||
);
|
||||
} else {
|
||||
$tplDumpPrepare->assign_block_vars(
|
||||
'SEND_MAIL.DONT_ATTACH_BACKUP', array()
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$tplDumpPrepare->assign_block_vars('NO_SEND_MAIL', array());
|
||||
}
|
||||
|
||||
$i = 1;
|
||||
foreach ($config['ftp'] as $ftp) {
|
||||
if ($ftp['transfer'] == 1) {
|
||||
$tplDumpPrepare->assign_block_vars(
|
||||
'FTP',
|
||||
array(
|
||||
'NR' => $i,
|
||||
'ROWCLASS' => $i % 2 ? 'dbrow1' : 'dbrow'
|
||||
)
|
||||
);
|
||||
|
||||
$tplDumpPrepare->assign_block_vars(
|
||||
'FTP.CONNECTION',
|
||||
array(
|
||||
'SERVER' => $ftp['server'],
|
||||
'PORT' => $ftp['port'],
|
||||
'DIR' => $ftp['dir']
|
||||
)
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
76
inc/dump/select_tables.php
Normale Datei
76
inc/dump/select_tables.php
Normale Datei
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @version SVN: $rev: 1207 $
|
||||
* @author $Author$
|
||||
* @lastmodified $Date$
|
||||
*/
|
||||
|
||||
if (!defined('MSD_VERSION')) {
|
||||
die('No direct access.');
|
||||
}
|
||||
// action is called, even if the checkbox "select tables" was not checked
|
||||
|
||||
// save selected values from the last site
|
||||
$dump['comment'] = $_POST['comment'];
|
||||
$dump['sel_dump_encoding'] = $_POST['sel_dump_encoding'];
|
||||
$dump['dump_encoding'] = $dump['sel_dump_encoding'];
|
||||
// we need to save this before the Ajax-Requests starts, so we are doing it here
|
||||
// although it is done in dump.php
|
||||
$_SESSION['dump'] = $dump;
|
||||
// checks after first dump-prepare if we need to head over to table selection
|
||||
// or if we can start the backup process
|
||||
if (!isset($_POST['tableselect'])) {
|
||||
// nothing to select - start dump action
|
||||
$action = 'do_dump';
|
||||
} else {
|
||||
// yes, we need to show the table-selection, but first save commetn and
|
||||
// encoding that was set before
|
||||
$tplDumpSelectTables = new MSDTemplate();
|
||||
$tplDumpSelectTables->set_filenames(
|
||||
array('tplDumpSelectTables' => 'tpl/dump/selectTables.tpl')
|
||||
);
|
||||
$dbo->selectDb($dump['db_actual']);
|
||||
$tables=$dbo->getTableStatus();
|
||||
$i=0;
|
||||
foreach ($tables as $tableName => $row) {
|
||||
$klasse = ($i % 2) ? 1 : '';
|
||||
$tableSize = byteOutput($row['Data_length'] + $row['Index_length']);
|
||||
$tableType = $row['Engine'];
|
||||
$nrOfRecords = String::formatNumber($row['Rows']);
|
||||
if (substr($row['Comment'], 0, 4) == 'VIEW' && $row['Engine'] == '') {
|
||||
$tableType = 'View';
|
||||
$tableSize = '-';
|
||||
$nrOfRecords = '-';
|
||||
}
|
||||
$tplDumpSelectTables->assign_block_vars(
|
||||
'ROW',
|
||||
array(
|
||||
'CLASS' => 'dbrow' . $klasse,
|
||||
'ID' => $i,
|
||||
'NR' => $i + 1,
|
||||
'TABLENAME' => $tableName,
|
||||
'TABLETYPE' => $tableType,
|
||||
'RECORDS' => $nrOfRecords,
|
||||
'SIZE' => $tableSize,
|
||||
'LAST_UPDATE' => $row['Update_time']
|
||||
)
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
|
||||
$tplDumpSelectTables->assign_vars(
|
||||
array(
|
||||
'PAGETITLE' => $lang['L_TABLESELECTION'],
|
||||
'SESSION_ID' => session_id(),
|
||||
'DATABASE' => $config['db_actual'],
|
||||
'ICON_OK' => $icon['ok'],
|
||||
'ICON_DELETE' => $icon['delete'],
|
||||
'ICON_DB' => $icon['db'],
|
||||
'L_NO_MSD_BACKUP' => $lang['L_NOT_SUPPORTED']
|
||||
)
|
||||
);
|
||||
}
|
||||
Laden …
Tabelle hinzufügen
Einen Link hinzufügen
In neuem Issue referenzieren