Restore backup feature
This commit is contained in:
parent
9037d2be50
commit
a66985a279
@ -77,17 +77,22 @@ if (file_exists($xmlfile))
|
||||
$xml = simplexml_load_file($xmlfile);
|
||||
if ($xml)
|
||||
{
|
||||
$ret = getFilesUpdated($xml->dolibarr_root_dir[0]); // Fill array $file_list
|
||||
$file_list = array();
|
||||
$ret = getFilesUpdated($file_list, $xml->dolibarr_root_dir[0]); // Fill array $file_list
|
||||
|
||||
print '<table class="noborder">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>' . $langs->trans("FilesMissing") . '</td>';
|
||||
print '<td align="center">' . $langs->trans("ExpectedChecksum") . '</td>';
|
||||
print '</tr>'."\n";
|
||||
$var = true;
|
||||
foreach ($file_list['missing'] as $file)
|
||||
$tmpfilelist = dol_sort_array($file_list['missing'], 'filename');
|
||||
foreach ($tmpfilelist as $file)
|
||||
{
|
||||
$var = !$var;
|
||||
print '<tr ' . $bc[$var] . '>';
|
||||
print '<td>'.$file.'</td>' . "\n";
|
||||
print '<td>'.$file['filename'].'</td>' . "\n";
|
||||
print '<td align="center">'.$file['expectedmd5'].'</td>' . "\n";
|
||||
print "</tr>\n";
|
||||
}
|
||||
print '</table>';
|
||||
@ -97,17 +102,22 @@ if (file_exists($xmlfile))
|
||||
print '<table class="noborder">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>' . $langs->trans("FilesUpdated") . '</td>';
|
||||
print '<td align="center">' . $langs->trans("ExpectedChecksum") . '</td>';
|
||||
print '<td align="center">' . $langs->trans("CurrentChecksum") . '</td>';
|
||||
print '<td align="right">' . $langs->trans("Size") . '</td>';
|
||||
print '<td align="center">' . $langs->trans("DateModification") . '</td>';
|
||||
print '<td align="right">' . $langs->trans("DateModification") . '</td>';
|
||||
print '</tr>'."\n";
|
||||
$var = true;
|
||||
foreach ($file_list['updated'] as $file)
|
||||
$tmpfilelist = dol_sort_array($file_list['updated'], 'filename');
|
||||
foreach ($tmpfilelist as $file)
|
||||
{
|
||||
$var = !$var;
|
||||
print '<tr ' . $bc[$var] . '>';
|
||||
print '<td>'.$file.'</td>' . "\n";
|
||||
print '<td align="right">'.dol_print_size(dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file)).'</td>' . "\n";
|
||||
print '<td align="center">'.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file),'dayhour').'</td>' . "\n";
|
||||
print '<td>'.$file['filename'].'</td>' . "\n";
|
||||
print '<td align="center">'.$file['expectedmd5'].'</td>' . "\n";
|
||||
print '<td align="center">'.$file['md5'].'</td>' . "\n";
|
||||
print '<td align="right">'.dol_print_size(dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename'])).'</td>' . "\n";
|
||||
print '<td align="right">'.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']),'dayhour').'</td>' . "\n";
|
||||
print "</tr>\n";
|
||||
}
|
||||
print '</table>';
|
||||
@ -124,34 +134,36 @@ $db->close();
|
||||
|
||||
|
||||
/**
|
||||
* Function to get list of updated or modified files
|
||||
* Function to get list of updated or modified files.
|
||||
* $file_list is used as global variable
|
||||
*
|
||||
* @param SimpleXMLElement $dir SimpleXMLElement of files to test
|
||||
* @param string $path Path of file
|
||||
* @return array Array of filenames
|
||||
* @param array $file_list Array for response
|
||||
* @param SimpleXMLElement $dir SimpleXMLElement of files to test
|
||||
* @param string $path Path of file
|
||||
* @return array Array of filenames
|
||||
*/
|
||||
function getFilesUpdated(SimpleXMLElement $dir, $path = '')
|
||||
function getFilesUpdated(&$file_list, SimpleXMLElement $dir, $path = '')
|
||||
{
|
||||
global $file_list;
|
||||
$exclude = 'install';
|
||||
|
||||
foreach ($dir->md5file as $file)
|
||||
{
|
||||
$filename = $path.$file['name'];
|
||||
|
||||
if (preg_match('#'.$exclude.'#', $filename))
|
||||
continue;
|
||||
if (preg_match('#'.$exclude.'#', $filename)) continue;
|
||||
|
||||
if (!file_exists(DOL_DOCUMENT_ROOT.'/'.$filename)) {
|
||||
$file_list['missing'][] = $filename;
|
||||
} else {
|
||||
if (!file_exists(DOL_DOCUMENT_ROOT.'/'.$filename))
|
||||
{
|
||||
$file_list['missing'][] = array('filename'=>$filename, 'expectedmd5'=>(string) $file);
|
||||
}
|
||||
else
|
||||
{
|
||||
$md5_local = md5_file(DOL_DOCUMENT_ROOT.'/'.$filename);
|
||||
if ($md5_local != (string) $file)
|
||||
$file_list['updated'][] = $filename;
|
||||
if ($md5_local != (string) $file) $file_list['updated'][] = array('filename'=>$filename, 'expectedmd5'=>(string) $file, 'md5'=>(string) $md5_local);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($dir->dir as $subdir)
|
||||
getFilesUpdated($subdir, $path.$subdir['name'].'/');
|
||||
return $file_list;
|
||||
foreach ($dir->dir as $subdir) getFilesUpdated($file_list, $subdir, $path.$subdir['name'].'/');
|
||||
|
||||
return $file_list;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -66,6 +66,8 @@ $form=new Form($db);
|
||||
$formfile = new FormFile($db);
|
||||
|
||||
$label=$db::LABEL;
|
||||
$type=$db->type;
|
||||
//var_dump($db);
|
||||
|
||||
$help_url='EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad';
|
||||
llxHeader('','',$help_url);
|
||||
@ -101,8 +103,8 @@ jQuery(document).ready(function() {
|
||||
});
|
||||
|
||||
<?php
|
||||
if ($label == 'MySQL') print 'jQuery("#radio_dump_mysql").click();';
|
||||
if ($label == 'PostgreSQL') print 'jQuery("#radio_dump_postgresql").click();';
|
||||
if (in_array($type, array('mysql', 'mysqli'))) print 'jQuery("#radio_dump_mysql").click();';
|
||||
if (in_array($type, array('pgsql'))) print 'jQuery("#radio_dump_postgresql").click();';
|
||||
?>
|
||||
});
|
||||
</script>
|
||||
@ -133,7 +135,7 @@ print '<br>';
|
||||
|
||||
print_titre($title?$title:$langs->trans("BackupDumpWizard"));
|
||||
|
||||
print '<table width="100%" class="'.($useinecm?'nobordernopadding':'liste').'">';
|
||||
print '<table width="100%" class="'.($useinecm?'nobordernopadding':'liste').' nohover">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre">';
|
||||
print $langs->trans("DatabaseName").' : <b>'.$dolibarr_main_db_name.'</b><br>';
|
||||
@ -148,7 +150,7 @@ print '<tr '.$bc[false].'><td style="padding-left: 8px">';
|
||||
<div id="div_container_exportoptions">
|
||||
<fieldset id="exportoptions"><legend><?php echo $langs->trans("ExportMethod"); ?></legend>
|
||||
<?php
|
||||
if ($label == 'MySQL')
|
||||
if (in_array($type, array('mysql', 'mysqli')))
|
||||
{
|
||||
?>
|
||||
<div class="formelementrow"><input type="radio" name="what" value="mysql" id="radio_dump_mysql" />
|
||||
@ -160,7 +162,7 @@ print '<tr '.$bc[false].'><td style="padding-left: 8px">';
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
else if ($label == 'PostgreSQL')
|
||||
else if (in_array($type, array('pgsql')))
|
||||
{
|
||||
?>
|
||||
<div class="formelementrow"><input type="radio" name="what" value="postgresql" id="radio_dump_postgresql" />
|
||||
@ -182,7 +184,7 @@ print '<tr '.$bc[false].'><td style="padding-left: 8px">';
|
||||
|
||||
<div id="div_container_sub_exportoptions">
|
||||
<?php
|
||||
if ($label == 'MySQL')
|
||||
if (in_array($type, array('mysql', 'mysqli')))
|
||||
{
|
||||
?> <!-- Fieldset mysqldump -->
|
||||
<fieldset id="mysql_options"><legend><?php echo $langs->trans("MySqlExportParameters"); ?></legend>
|
||||
@ -317,7 +319,7 @@ print '<tr '.$bc[false].'><td style="padding-left: 8px">';
|
||||
<?php
|
||||
}
|
||||
|
||||
if ($label == 'PostgreSQL')
|
||||
if (in_array($type, array('pgsql')))
|
||||
{
|
||||
?> <!-- Fieldset pg_dump -->
|
||||
<fieldset id="postgresql_options"><legend><?php echo $langs->trans("PostgreSqlExportParameters"); ?></legend>
|
||||
@ -382,9 +384,9 @@ print '<tr '.$bc[false].'><td style="padding-left: 8px">';
|
||||
value="<?php
|
||||
$prefix='dump';
|
||||
$ext='.sql';
|
||||
if ($label == 'MySQL') { $prefix='mysqldump'; $ext='sql'; }
|
||||
if (in_array($type, array('mysql', 'mysqli'))) { $prefix='mysqldump'; $ext='sql'; }
|
||||
//if ($label == 'PostgreSQL') { $prefix='pg_dump'; $ext='dump'; }
|
||||
if ($label == 'PostgreSQL') { $prefix='pg_dump'; $ext='sql'; }
|
||||
if (in_array($type, array('pgsql'))) { $prefix='pg_dump'; $ext='sql'; }
|
||||
$file=$prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M").'.'.$ext;
|
||||
echo $file;
|
||||
?>" /> <br>
|
||||
@ -394,7 +396,7 @@ echo $file;
|
||||
|
||||
// Define compressions array
|
||||
$compression=array();
|
||||
if ($label == 'MySQL')
|
||||
if (in_array($type, array('mysql', 'mysqli')))
|
||||
{
|
||||
$compression['none'] = array('function' => '', 'id' => 'radio_compression_none', 'label' => $langs->trans("None"));
|
||||
$compression['gz'] = array('function' => 'gzopen', 'id' => 'radio_compression_gzip', 'label' => $langs->trans("Gzip"));
|
||||
|
||||
@ -1023,7 +1023,7 @@ NoEventOrNoAuditSetup=No security event has been recorded yet. This can be norma
|
||||
NoEventFoundWithCriteria=No security event has been found for such search criterias.
|
||||
SeeLocalSendMailSetup=See your local sendmail setup
|
||||
BackupDesc=To make a complete backup of Dolibarr, you must:
|
||||
BackupDesc2=Save content of documents directory (<b>%s</b>) that contains all uploaded and generated files (you can make a zip for example).
|
||||
BackupDesc2=Save content of documents directory (<b>%s</b>) that contains all uploaded and generated files (So it includes all dump files generated at step 1).
|
||||
BackupDesc3=Save content of your database (<b>%s</b>) into a dump file. For this, you can use following assistant.
|
||||
BackupDescX=Archived directory should be stored in a secure place.
|
||||
BackupDescY=The generated dump file should be stored in a secure place.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user