From e6c9e07de42f7b8851e262401c5a0847e4903fb2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 3 Apr 2015 17:17:02 +0200 Subject: [PATCH] NEW Backup and restore tool is easier to use --- htdocs/admin/tools/dolibarr_export.php | 75 +++++++++++++++++++------- htdocs/admin/tools/dolibarr_import.php | 17 ++++-- htdocs/admin/tools/export.php | 58 +++++++++++++------- htdocs/langs/en_US/admin.lang | 9 ++-- htdocs/theme/eldy/style.css.php | 2 +- 5 files changed, 117 insertions(+), 44 deletions(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index aec78f8aaac..c1f44b7c791 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -111,11 +111,6 @@ jQuery(document).ready(function() { print_fiche_titre($langs->trans("Backup"),'','setup'); print $langs->trans("BackupDesc",DOL_DATA_ROOT).'<br><br>'; -print $langs->trans("BackupDesc2",DOL_DATA_ROOT).'<br>'; -print $langs->trans("BackupDescX").'<br><br>'; -print $langs->trans("BackupDesc3",DOL_DATA_ROOT).'<br>'; -print $langs->trans("BackupDescY").'<br><br>'; - ?> @@ -124,9 +119,29 @@ print $langs->trans("BackupDescY").'<br><br>'; name="token" value="<?php echo $_SESSION['newtoken']; ?>" /> <input type="hidden" name="export_type" value="server" /> -<fieldset id="fieldsetexport"> -<?php print '<legend>'.$langs->trans("DatabaseName").' : <b>'.$dolibarr_main_db_name.'</b></legend>'; ?> -<table> +<fieldset id="fieldsetexport"><legend style="font-size: 3em">1</legend> + +<?php +print $langs->trans("BackupDesc3",$dolibarr_main_db_name).'<br>'; +//print $langs->trans("BackupDescY").'<br>'; +print '<br>'; +?> + +<div id="backupdatabaseleft" class="fichehalfleft" > + +<?php + +print_titre($title?$title:$langs->trans("BackupDumpWizard")); + +print '<table width="100%" class="'.($useinecm?'nobordernopadding':'liste').'">'; +print '<tr class="liste_titre">'; +print '<td class="liste_titre">'; +print $langs->trans("DatabaseName").' : <b>'.$dolibarr_main_db_name.'</b><br>'; +print '</td>'; +print '</tr>'; +print '<tr '.$bc[false].'><td style="padding-left: 8px">'; +?> +<table class="centpercent"> <tr> <td valign="top"> @@ -182,7 +197,7 @@ print $langs->trans("BackupDescY").'<br><br>'; $fullpathofmysqldump=$conf->global->SYSTEMTOOLS_MYSQLDUMP; } ?><br> - <input type="text" name="mysqldump" size="80" + <input type="text" name="mysqldump" style="width: 80%" value="<?php echo $fullpathofmysqldump; ?>" /></div> <br> @@ -317,7 +332,7 @@ print $langs->trans("BackupDescY").'<br><br>'; $fullpathofpgdump=$conf->global->SYSTEMTOOLS_POSTGRESQLDUMP; } ?><br> - <input type="text" name="postgresqldump" size="80" + <input type="text" name="postgresqldump" style="width: 80%" value="<?php echo $fullpathofpgdump; ?>" /></div> @@ -357,12 +372,12 @@ print $langs->trans("BackupDescY").'<br><br>'; </tr> </table> -</fieldset> -<fieldset> -<legend><?php echo $langs->trans("Destination"); ?></legend> -<label for="filename_template"> <?php echo $langs->trans("FileNameToGenerate"); ?></label>: - <input type="text" name="filename_template" size="60" +<!--<fieldset> +<legend><?php echo $langs->trans("Destination"); ?></legend> --> +<br> +<label for="filename_template"> <?php echo $langs->trans("FileNameToGenerate"); ?></label><br> +<input type="text" name="filename_template" style="width: 90%" id="filename_template" value="<?php $prefix='dump'; @@ -417,7 +432,8 @@ foreach($compression as $key => $val) print '</div>'; print "\n"; -?></fieldset> +?><!--</fieldset>--> <!-- End destination --> + <br> <div align="center"><input type="submit" class="button" @@ -425,15 +441,38 @@ print "\n"; <br> </div> +<?php +print '</td></tr></table>'; +?> -</form> +</div> +<div id="backupdatabaseright" class="fichehalfright" style="height:400px; overflow: auto;"> +<div class="ficheaddleft"> <?php - $filearray=dol_dir_list($conf->admin->dir_output.'/backup','files',0,'','',$sortfield,(strtolower($sortorder)=='asc'?SORT_ASC:SORT_DESC),1); $result=$formfile->list_of_documents($filearray,null,'systemtools','',1,'backup/',1,0,$langs->trans("NoBackupFileAvailable"),0,$langs->trans("PreviousDumpFiles")); print '<br>'; +?> + +</div> +</div> +</fieldset> + +<br> + +<fieldset><legend style="font-size: 3em">2</legend> +<?php +print $langs->trans("BackupDesc2",DOL_DATA_ROOT).'<br>'; +print $langs->trans("BackupDescX").'<br><br>'; +?> +</fieldset> + + + +</form> +<?php llxFooter(); diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php index 0cd1ae19fa9..6072ba6e8f4 100644 --- a/htdocs/admin/tools/dolibarr_import.php +++ b/htdocs/admin/tools/dolibarr_import.php @@ -66,13 +66,24 @@ jQuery(document).ready(function() { print_fiche_titre($langs->trans("Restore"),'','setup'); print $langs->trans("RestoreDesc",DOL_DATA_ROOT).'<br><br>'; +?> +<fieldset> +<legend style="font-size: 3em">1</legend> +<?php print $langs->trans("RestoreDesc2",DOL_DATA_ROOT).'<br><br>'; -print $langs->trans("RestoreDesc3",DOL_DATA_ROOT).'<br><br>'; +?> +</fieldset> +<br> + +<fieldset> +<legend style="font-size: 3em">2</legend> +<?php +print $langs->trans("RestoreDesc3",$dolibarr_main_db_name).'<br><br>'; ?> -<fieldset id="fieldsetexport"> -<?php print '<legend>'.$langs->trans("DatabaseName").' : <b>'.$dolibarr_main_db_name.'</b></legend>'; ?> +<?php print $langs->trans("DatabaseName").' : <b>'.$dolibarr_main_db_name.'</b>'; ?><br><br> + <table><tr><td valign="top"> <?php if ($conf->use_javascript_ajax) { ?> diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index 1668e4f4c67..ba3da7b443c 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -88,10 +88,10 @@ if (!empty($MemoryLimit)) $form=new Form($db); $formfile = new FormFile($db); -$help_url='EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad'; -llxHeader('','',$help_url); +//$help_url='EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad'; +//llxHeader('','',$help_url); -print_fiche_titre($langs->trans("Backup"),'','setup'); +//print_fiche_titre($langs->trans("Backup"),'','setup'); // Start with empty buffer @@ -165,13 +165,18 @@ if ($what == 'mysql') $paramclear.=' -p"'.str_replace(array('"','`'),array('\"','\`'),$dolibarr_main_db_pass).'"'; } + $_SESSION["commandbackuplastdone"]=$command." ".$paramcrypted; + $_SESSION["commandbackuptorun"]=""; + /* print '<b>'.$langs->trans("RunCommandSummary").':</b><br>'."\n"; print '<textarea rows="'.ROWS_2.'" cols="120">'.$command." ".$paramcrypted.'</textarea><br>'."\n"; print '<br>'; + //print $paramclear; // Now run command and show result print '<b>'.$langs->trans("BackupResult").':</b> '; + */ $errormsg=''; @@ -264,6 +269,9 @@ if ($what == 'mysqlnobin') { backup_tables($outputfile); } + + $_SESSION["commandbackuplastdone"]=""; + $_SESSION["commandbackuptorun"]=""; } // POSTGRESQL @@ -320,7 +328,9 @@ if ($what == 'postgresql') $paramcrypted.=" -w ".$dolibarr_main_db_name; $paramclear.=" -w ".$dolibarr_main_db_name; - print $langs->trans("RunCommandSummaryToLaunch").':<br>'."\n"; + $_SESSION["commandbackuplastdone"]=""; + $_SESSION["commandbackuptorun"]=$command." ".$paramcrypted; + /*print $langs->trans("RunCommandSummaryToLaunch").':<br>'."\n"; print '<textarea rows="'.ROWS_3.'" cols="120">'.$command." ".$paramcrypted.'</textarea><br>'."\n"; print '<br>'; @@ -330,7 +340,7 @@ if ($what == 'postgresql') print $langs->trans("YouMustRunCommandFromCommandLineAfterLoginToUser",$dolibarr_main_db_user,$dolibarr_main_db_user); print '<br>'; - print '<br>'; + print '<br>';*/ $what=''; } @@ -339,33 +349,45 @@ if ($what == 'postgresql') // Si on a demande une generation -if ($what) -{ +//if ($what) +//{ if ($errormsg) { + setEventMessage($langs->trans("Error")." : ".$errormsg, 'errors'); + /* print '<div class="error">'.$langs->trans("Error")." : ".$errormsg.'</div>'; - // print '<a href="'.DOL_URL_ROOT.$relativepatherr.'">'.$langs->trans("DownloadErrorFile").'</a><br>'; - print '<br>'; print '<br>'; + print '<br>';*/ } else - { - print '<div class="ok">'; - print $langs->trans("BackupFileSuccessfullyCreated").'.<br>'; - print $langs->trans("YouCanDownloadBackupFile"); - print '</div>'; - print '<br>'; + { + if ($what) + { + setEventMessage($langs->trans("BackupFileSuccessfullyCreated").'.<br>'.$langs->trans("YouCanDownloadBackupFile")); + /*print '<div class="ok">'; + print $langs->trans("BackupFileSuccessfullyCreated").'.<br>'; + print $langs->trans("YouCanDownloadBackupFile"); + print '</div>'; + print '<br>';*/ + } + else + { + setEventMessage($langs->trans("YouMustRunCommandFromCommandLineAfterLoginToUser",$dolibarr_main_db_user,$dolibarr_main_db_user)); + } } -} +//} +/* $filearray=dol_dir_list($conf->admin->dir_output.'/backup','files',0,'','',$sortfield,(strtolower($sortorder)=='asc'?SORT_ASC:SORT_DESC),1); $result=$formfile->list_of_documents($filearray,null,'systemtools','',1,'backup/',1,0,($langs->trans("NoBackupFileAvailable").'<br>'.$langs->trans("ToBuildBackupFileClickHere",DOL_URL_ROOT.'/admin/tools/dolibarr_export.php')),0,$langs->trans("PreviousDumpFiles")); print '<br>'; +*/ -$time_end = time(); +// Redirect t backup page +header("Location: dolibarr_export.php"); -llxFooter(); +$time_end = time(); $db->close(); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 3d767ba8524..b24e108c80f 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1018,14 +1018,14 @@ 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). -BackupDesc3=* Save content of your database into a dump file. For this, you can use following assistant. +BackupDesc2=Save content of documents directory (<b>%s</b>) that contains all uploaded and generated files (you can make a zip for example). +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. BackupPHPWarning=Backup can't be guaranted with this method. Prefer previous one RestoreDesc=To restore a Dolibarr backup, you must: -RestoreDesc2=* Restore archive file (zip file for example) of documents directory to extract tree of files in documents directory of a new Dolibarr installation or into this current documents directoy (<b>%s</b>). -RestoreDesc3=* Restore the data, from a backup dump file, into the database of the new Dolibarr installation or into the database of this current installation. Warning, once restore is finished, you must use a login/password, that existed when backup was made, to connect again. To restore a backup database into this current installation, you can follow this assistant. +RestoreDesc2=Restore archive file (zip file for example) of documents directory to extract tree of files in documents directory of a new Dolibarr installation or into this current documents directoy (<b>%s</b>). +RestoreDesc3=Restore the data, from a backup dump file, into the database of the new Dolibarr installation or into the database of this current installation (<b>%s</b>). Warning, once restore is finished, you must use a login/password, that existed when backup was made, to connect again. To restore a backup database into this current installation, you can follow this assistant. RestoreMySQL=MySQL import ForcedToByAModule= This rule is forced to <b>%s</b> by an activated module PreviousDumpFiles=Available database backup dump files @@ -1616,3 +1616,4 @@ ListOfNotificationsPerContact=List of notifications per contact* ListOfFixedNotifications=List of fixed notifications GoOntoContactCardToAddMore=Go on the tab "Notifications" of a thirdparty contact to add or remove notifications for contacts/addresses Threshold=Threshold +BackupDumpWizard=Wizard to build database backup dump file diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 0537d13b80d..b356f570cba 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -269,7 +269,7 @@ input, textarea, select { border-bottom:solid 1px rgba(0,0,0,.2); /* box-shadow: 1px 1px 1px rgba(0,0,0,.2) inset;*/ padding:4px; - margin-left:1px; + margin-left:0px; margin-bottom:1px; margin-top:1px; } -- GitLab