backup dir can be set in configuration

This commit is contained in:
Uwe Steinmann 2017-11-21 11:51:45 +01:00
parent 78f4d62e36
commit 545cdb4e32
5 changed files with 41 additions and 19 deletions

View File

@ -89,6 +89,8 @@ class Settings { /* {{{ */
var $_luceneDir = null;
// Where the drop folders are located
var $_dropFolderDir = null;
// Where the backup directory is located
var $_backupDir = null;
// enable removal of file from dropfolder after success import
var $_removeFromDropFolder = false;
// Where the stop word file is located
@ -467,6 +469,7 @@ class Settings { /* {{{ */
$this->_stagingDir = strval($tab["stagingDir"]);
$this->_luceneDir = strval($tab["luceneDir"]);
$this->_dropFolderDir = strval($tab["dropFolderDir"]);
$this->_backupDir = strval($tab["backupDir"]);
$this->_logFileEnable = Settings::boolVal($tab["logFileEnable"]);
$this->_logFileRotation = strval($tab["logFileRotation"]);
$this->_enableLargeFileUpload = Settings::boolVal($tab["enableLargeFileUpload"]);
@ -779,6 +782,7 @@ class Settings { /* {{{ */
$this->setXMLAttributValue($node, "stagingDir", $this->_stagingDir);
$this->setXMLAttributValue($node, "luceneDir", $this->_luceneDir);
$this->setXMLAttributValue($node, "dropFolderDir", $this->_dropFolderDir);
$this->setXMLAttributValue($node, "backupDir", $this->_backupDir);
$this->setXMLAttributValue($node, "logFileEnable", $this->_logFileEnable);
$this->setXMLAttributValue($node, "logFileRotation", $this->_logFileRotation);
$this->setXMLAttributValue($node, "enableLargeFileUpload", $this->_enableLargeFileUpload);

View File

@ -114,6 +114,7 @@ if ($action == "saveSettings")
$settings->_luceneDir = addDirSep($_POST["luceneDir"]);
$settings->_extraPath = addDirSep($_POST["extraPath"]);
$settings->_dropFolderDir = addDirSep($_POST["dropFolderDir"]);
$settings->_backupDir = addDirSep($_POST["backupDir"]);
$settings->_logFileEnable = getBoolValue("logFileEnable");
$settings->_logFileRotation = $_POST["logFileRotation"];
$settings->_enableLargeFileUpload = getBoolValue("enableLargeFileUpload");

View File

@ -34,6 +34,13 @@ if (!$user->isAdmin()) {
}
if($view) {
if($settings->_backupDir && file_exists($settings->_backupDir)) {
$view->setParam('backupdir', $settings->_backupDir);
$view->setParam('hasbackupdir', true);
} else {
$view->setParam('backupdir', $settings->_contentDir);
$view->setParam('hasbackupdir', false);
}
$view($_GET);
exit;
}

View File

@ -42,24 +42,29 @@ class SeedDMS_View_BackupTools extends SeedDMS_Bootstrap_Style {
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$contentdir = $this->params['contentdir'];
$backupdir = $this->params['backupdir'];
$this->htmlStartPage(getMLText("backup_tools"));
$this->globalNavigation();
$this->contentStart();
$this->pageNavigation(getMLText("admin_tools"), "admin_tools");
$this->contentHeading(getMLText("backup_tools"));
$this->contentContainerStart();
print getMLText("space_used_on_data_folder")." : ".SeedDMS_Core_File::format_filesize(dskspace($contentdir));
$this->contentContainerEnd();
/* Calculating the size of the backup dir is only reasonable if
* it is not part of the content dir. Otherwise the content will
* be counted as well.
*/
if($this->params['hasbackupdir']) {
$this->contentHeading(getMLText("backup_tools"));
$this->contentContainerStart();
print getMLText("space_used_on_data_folder")." : ".SeedDMS_Core_File::format_filesize(dskspace($backupdir));
$this->contentContainerEnd();
}
// versioning file creation ////////////////////////////////////////////////////
$this->contentHeading(getMLText("versioning_file_creation"));
$this->contentContainerStart();
print "<p>".getMLText("versioning_file_creation_warning")."</p>\n";
$this->contentContainerStart();
print "<form class=\"form-inline\" action=\"../op/op.CreateVersioningFiles.php\" name=\"form1\">";
$this->printFolderChooserHtml("form1",M_READWRITE);
print "<input type='submit' class='btn' name='' value='".getMLText("versioning_file_creation")."'/>";
@ -70,9 +75,8 @@ class SeedDMS_View_BackupTools extends SeedDMS_Bootstrap_Style {
// archive creation ////////////////////////////////////////////////////////////
$this->contentHeading(getMLText("archive_creation"));
$this->contentContainerStart();
print "<p>".getMLText("archive_creation_warning")."</p>\n";
$this->contentContainerStart();
print "<form action=\"../op/op.CreateFolderArchive.php\" name=\"form2\">";
$this->printFolderChooserHtml("form2",M_READWRITE);
print "<label class=\"checkbox\"><input type=\"checkbox\" name=\"human_readable\" value=\"1\">".getMLText("human_readable")."</label>";
@ -81,10 +85,10 @@ class SeedDMS_View_BackupTools extends SeedDMS_Bootstrap_Style {
// list backup files
$handle = opendir($contentdir);
$handle = opendir($backupdir);
$entries = array();
while ($e = readdir($handle)){
if (is_dir($contentdir.$e)) continue;
if (is_dir($backupdir.$e)) continue;
if (strpos($e,".tar.gz")==FALSE) continue;
$entries[] = $e;
}
@ -113,8 +117,8 @@ class SeedDMS_View_BackupTools extends SeedDMS_Bootstrap_Style {
print "<td><a href=\"../op/op.Download.php?arkname=".$entry."\">".$entry."</a></td>\n";
if (is_object($folder)) print "<td>".htmlspecialchars($folder->getName())."</td>\n";
else print "<td>".getMLText("unknown_id")."</td>\n";
print "<td>".getLongReadableDate(filectime($contentdir.$entry))."</td>\n";
print "<td>".SeedDMS_Core_File::format_filesize(filesize($contentdir.$entry))."</td>\n";
print "<td>".getLongReadableDate(filectime($backupdir.$entry))."</td>\n";
print "<td>".SeedDMS_Core_File::format_filesize(filesize($backupdir.$entry))."</td>\n";
print "<td>";
print "<a href=\"out.RemoveArchive.php?arkname=".$entry."\" class=\"btn btn-mini\"><i class=\"icon-remove\"></i> ".getMLText("backup_remove")."</a>";
print "</td>\n";
@ -128,18 +132,18 @@ class SeedDMS_View_BackupTools extends SeedDMS_Bootstrap_Style {
// dump creation ///////////////////////////////////////////////////////////////
$this->contentHeading(getMLText("dump_creation"));
$this->contentContainerStart();
print "<p>".getMLText("dump_creation_warning")."</p>\n";
$this->contentContainerStart();
print "<form action=\"../op/op.CreateDump.php\" name=\"form4\">";
print "<input type='submit' class='btn' name='' value='".getMLText("dump_creation")."'/>";
print "</form>\n";
// list backup files
$handle = opendir($contentdir);
$handle = opendir($backupdir);
$entries = array();
while ($e = readdir($handle)){
if (is_dir($contentdir.$e)) continue;
if (is_dir($backupdir.$e)) continue;
if (strpos($e,".sql.gz")==FALSE) continue;
$entries[] = $e;
}
@ -160,9 +164,11 @@ class SeedDMS_View_BackupTools extends SeedDMS_Bootstrap_Style {
foreach ($entries as $entry){
print "<tr>\n";
print "<td><a href=\"../op/op.Download.php?dumpname=".$entry."\">".$entry."</a></td>\n";
print "<td>".getLongReadableDate(filectime($contentdir.$entry))."</td>\n";
print "<td>".SeedDMS_Core_File::format_filesize(filesize($contentdir.$entry))."</td>\n";
print "<td>";
print "<a href=\"../op/op.Download.php?dumpname=".$entry."\">".$entry."</a>";
print "</td>\n";
print "<td>".getLongReadableDate(filectime($backupdir.$entry))."</td>\n";
print "<td>".SeedDMS_Core_File::format_filesize(filesize($backupdir.$entry))."</td>\n";
print "<td>";
print "<a href=\"out.RemoveDump.php?dumpname=".$entry."\" class=\"btn btn-mini\"><i class=\"icon-remove\"></i> ".getMLText("dump_remove")."</a>";
print "</td>\n";

View File

@ -398,6 +398,10 @@ if(!is_writeable($settings->_configFilePath)) {
<td><?php printMLText("settings_contentDir");?>:</td>
<td><?php $this->showTextField("contentDir", $settings->_contentDir); ?></td>
</tr>
<tr title="<?php printMLText("settings_backupDir_desc");?>">
<td><?php printMLText("settings_backupDir");?>:</td>
<td><?php $this->showTextField("backupDir", $settings->_backupDir); ?></td>
</tr>
<tr title="<?php printMLText("settings_cacheDir_desc");?>">
<td><?php printMLText("settings_cacheDir");?>:</td>
<td><?php $this->showTextField("cacheDir", $settings->_cacheDir); ?></td>