Skip to content

Commit

Permalink
NEW Backup and restore tool is easier to use
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Apr 3, 2015
1 parent f38bf5a commit e6c9e07
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 44 deletions.
75 changes: 57 additions & 18 deletions htdocs/admin/tools/dolibarr_export.php
Expand Up @@ -111,11 +111,6 @@ function hideoptions () {
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>';


?>

Expand All @@ -124,9 +119,29 @@ function hideoptions () {
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">

Expand Down Expand Up @@ -182,7 +197,7 @@ function hideoptions () {
$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>
Expand Down Expand Up @@ -317,7 +332,7 @@ function hideoptions () {
$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>


Expand Down Expand Up @@ -357,12 +372,12 @@ function hideoptions () {
</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';
Expand Down Expand Up @@ -417,23 +432,47 @@ function hideoptions () {
print '</div>';
print "\n";

?></fieldset>
?><!--</fieldset>--> <!-- End destination -->


<br>
<div align="center"><input type="submit" class="button"
value="<?php echo $langs->trans("GenerateBackup") ?>" id="buttonGo" /><br>
<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();

Expand Down
17 changes: 14 additions & 3 deletions htdocs/admin/tools/dolibarr_import.php
Expand Up @@ -66,13 +66,24 @@
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) { ?>
Expand Down
58 changes: 40 additions & 18 deletions htdocs/admin/tools/export.php
Expand Up @@ -88,10 +88,10 @@
$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
Expand Down Expand Up @@ -165,13 +165,18 @@
$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='';

Expand Down Expand Up @@ -264,6 +269,9 @@
{
backup_tables($outputfile);
}

$_SESSION["commandbackuplastdone"]="";
$_SESSION["commandbackuptorun"]="";
}

// POSTGRESQL
Expand Down Expand Up @@ -320,7 +328,9 @@
$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>';
Expand All @@ -330,7 +340,7 @@
print $langs->trans("YouMustRunCommandFromCommandLineAfterLoginToUser",$dolibarr_main_db_user,$dolibarr_main_db_user);
print '<br>';
print '<br>';
print '<br>';*/

$what='';
}
Expand All @@ -339,33 +349,45 @@


// 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();

Expand Down
9 changes: 5 additions & 4 deletions htdocs/langs/en_US/admin.lang
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion htdocs/theme/eldy/style.css.php
Expand Up @@ -269,7 +269,7 @@
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;
}
Expand Down

0 comments on commit e6c9e07

Please sign in to comment.