From b21e7cd69f2a9aba2f0c54f3fb8094006bace81a Mon Sep 17 00:00:00 2001 From: Robin Kluth Date: Mon, 26 Feb 2024 17:43:11 +0100 Subject: [PATCH 1/6] Toggle advanced settings instead just show it --- src/pages/content/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/content/settings.php b/src/pages/content/settings.php index 8af6e95..ab90ab0 100644 --- a/src/pages/content/settings.php +++ b/src/pages/content/settings.php @@ -630,7 +630,7 @@ class="fa fa-clock-o title">Notifications and scheduling -
Show advanced options
+
Show advanced options
Skip backup? Only stop/start
From 6a494a0c0a239ed8bdf134ed4a4382b38b78e8cc Mon Sep 17 00:00:00 2001 From: Robin Kluth Date: Mon, 26 Feb 2024 17:43:46 +0100 Subject: [PATCH 2/6] Debug for volume mapping duplicate detection --- src/pages/content/settings.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/content/settings.php b/src/pages/content/settings.php index ab90ab0..1b8bc8f 100644 --- a/src/pages/content/settings.php +++ b/src/pages/content/settings.php @@ -1018,6 +1018,8 @@ function checkVolumesForDuplicates() { } }); + console.debug("Volume dup check (affected/matrix): ", affectedMappings, volumeMatrix); + affectedMappings.forEach(function (element) { let codeElems = $('code:contains(' + element + ')'); codeElems.each(function () { From b165af1a2db190ee3aad8529a6f67ce130828698 Mon Sep 17 00:00:00 2001 From: Robin Kluth Date: Mon, 26 Feb 2024 18:01:43 +0100 Subject: [PATCH 3/6] Make grouping input visible to dark theme user --- src/pages/content/settings.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/content/settings.php b/src/pages/content/settings.php index 1b8bc8f..63e6713 100644 --- a/src/pages/content/settings.php +++ b/src/pages/content/settings.php @@ -172,8 +172,9 @@ } - blockquote select, blockquote textarea { + blockquote select, blockquote textarea, blockquote input[type="text"] { border-bottom: ; + color: ; } From 5b728ea0de9db07aa07713beb9ecdde41d055a4c Mon Sep 17 00:00:00 2001 From: Robin Kluth Date: Mon, 26 Feb 2024 18:41:02 +0100 Subject: [PATCH 4/6] Respect container exclusion list for volume determination --- src/include/ABHelper.php | 15 ++++++++++----- src/include/ABSettings.php | 21 +++++++++++++++++++-- src/pages/content/settings.php | 6 ++++-- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/include/ABHelper.php b/src/include/ABHelper.php index 08dcb3b..cd37ad3 100644 --- a/src/include/ABHelper.php +++ b/src/include/ABHelper.php @@ -361,10 +361,8 @@ public static function backupContainer($container, $destination) { $tarExcludes = []; if (!empty($containerSettings['exclude'])) { - self::backupLog("Container got excludes! " . PHP_EOL . print_r($containerSettings['exclude'], true), self::LOGLEVEL_DEBUG); - $excludes = explode("\r\n", $containerSettings['exclude']); - if (!empty($excludes)) { - foreach ($excludes as $exclude) { + self::backupLog("Container got excludes! " . implode(", ", $containerSettings['exclude']), self::LOGLEVEL_DEBUG); + foreach ($containerSettings['exclude'] as $exclude) { $exclude = rtrim($exclude, "/"); if (!empty($exclude)) { if (($volumeKey = array_search($exclude, $volumes)) !== false) { @@ -375,7 +373,6 @@ public static function backupContainer($container, $destination) { $tarExcludes[] = '--exclude ' . escapeshellarg($exclude); } } - } } if (!empty($abSettings->globalExclusions)) { @@ -512,6 +509,14 @@ public static function getContainerVolumes($container) { self::backupLog("This volume is empty (rootfs mapped??)! Ignoring.", self::LOGLEVEL_DEBUG); continue; } + + $containerSettings = $abSettings->getContainerSpecificSettings($container['Name']); + + if (in_array($hostPath, $containerSettings['exclude'])) { + self::backupLog("Ignoring '$hostPath' because its listed in containers exclusions list!", self::LOGLEVEL_DEBUG); + continue; + } + if (!file_exists($hostPath)) { self::backupLog("'$hostPath' does NOT exist! Please check your mappings! Skipping it for now.", self::LOGLEVEL_ERR); continue; diff --git a/src/include/ABSettings.php b/src/include/ABSettings.php index d675c2f..60f7047 100644 --- a/src/include/ABSettings.php +++ b/src/include/ABSettings.php @@ -51,7 +51,7 @@ class ABSettings { // The following are hidden, container special default settings 'skip' => 'no', - 'exclude' => '', + 'exclude' => [], 'dontStop' => 'no', 'backupExtVolumes' => 'no' ]; @@ -111,6 +111,23 @@ public function __construct() { case 'settingsVersion': $this::$settingsVersion = $value; break; + case 'containerSettings': + /** + * Container specific patches + */ + foreach ($value as $containerName => $containerSettings) { + $paths = explode("\r\n", $containerSettings['exclude']); + $newPaths = []; + foreach ($paths as $pathKey => $path) { + if (empty(trim($path))) { + continue; // Skip empty lines + } + $newPaths[] = rtrim($path, '/'); + } + $value[$containerName]['exclude'] = $newPaths; + } + $this->$key = $value; + break; default: $this->$key = $value; break; @@ -217,7 +234,7 @@ public function getContainerSpecificSettings($name, $setEmptyToDefault = true) { * Container is unknown, init its values with empty strings = 'use default' */ foreach ($this->defaults as $setting => $value) { - $this->containerSettings[$name][$setting] = ''; + $this->containerSettings[$name][$setting] = is_array($value) ? [] : ''; } } diff --git a/src/pages/content/settings.php b/src/pages/content/settings.php index 63e6713..297bd42 100644 --- a/src/pages/content/settings.php +++ b/src/pages/content/settings.php @@ -589,6 +589,8 @@ class="fa fa-clock-o title">Notifications and scheduling $containerSetting = $abSettings->getContainerSpecificSettings($container['Name'], false); $realContainerSetting = print_r($abSettings->getContainerSpecificSettings($container['Name']), true); + $containerExcludes = implode("\r\n", $containerSetting['exclude']); + echo <<$realContainerSetting
@@ -626,7 +628,7 @@ class="fa fa-clock-o title">Notifications and scheduling
Excluded folders/files
One path/pattern per line. See belows "Global exclusions" for more examples.
-
+
@@ -1022,7 +1024,7 @@ function checkVolumesForDuplicates() { console.debug("Volume dup check (affected/matrix): ", affectedMappings, volumeMatrix); affectedMappings.forEach(function (element) { - let codeElems = $('code:contains(' + element + ')'); + let codeElems = $('code[data-container]:contains(' + element + ')'); codeElems.each(function () { $('#containerMultiMappingIssue_' + $(this).data('container')).show(); $(this).next('.multiVolumeWarn').show(); From 6cd6fc2b29133870a965b5d82aa10903e2e65ecb Mon Sep 17 00:00:00 2001 From: Robin Kluth Date: Mon, 26 Feb 2024 18:54:51 +0100 Subject: [PATCH 5/6] Better textarea values pasring. --- src/pages/content/settings.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/content/settings.php b/src/pages/content/settings.php index 297bd42..ee7cb5e 100644 --- a/src/pages/content/settings.php +++ b/src/pages/content/settings.php @@ -951,7 +951,8 @@ function addVolumeToExclude(element) { $path = $(element).text(); $excludeTextarea = $('#' + $(element).data('container') + '_exclude'); - if ($excludeTextarea.val().indexOf($path) !== -1) { // If existing inside textarea + if ($excludeTextarea.val().split(/\r?\n|\r|\n/g).includes($path)) { // If existing inside textarea + console.debug("Not adding this volume to exclusion: already listed!") return; } @@ -1012,9 +1013,8 @@ function checkVolumesForDuplicates() { $("code[data-container]").each(function () { let container = $(this).data('container'); let mapping = $(this).text(); - if ($('#' + container + '_exclude').val().indexOf(mapping) !== -1) { - console.debug(container, mapping, 'is excluded so ignored'); - } else if (volumeMatrix.includes(mapping)) { + + if (volumeMatrix.includes(mapping)) { affectedMappings.push(mapping); } else { volumeMatrix.push($(this).text()); From 9a2930cdda40ec666f827588fe82507b75b3afc3 Mon Sep 17 00:00:00 2001 From: Robin Kluth Date: Mon, 26 Feb 2024 19:03:18 +0100 Subject: [PATCH 6/6] Show container volumes with `excluded` suffix, if listed in exclusions list --- src/include/ABHelper.php | 12 +++++++----- src/pages/content/settings.php | 10 +++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/include/ABHelper.php b/src/include/ABHelper.php index cd37ad3..0cda25a 100644 --- a/src/include/ABHelper.php +++ b/src/include/ABHelper.php @@ -499,7 +499,7 @@ public static function abortRequested() { * @param $container * @return array */ - public static function getContainerVolumes($container) { + public static function getContainerVolumes($container, $skipExclusionCheck = false) { global $abSettings; $volumes = []; @@ -510,11 +510,13 @@ public static function getContainerVolumes($container) { continue; } - $containerSettings = $abSettings->getContainerSpecificSettings($container['Name']); + if (!$skipExclusionCheck) { + $containerSettings = $abSettings->getContainerSpecificSettings($container['Name']); - if (in_array($hostPath, $containerSettings['exclude'])) { - self::backupLog("Ignoring '$hostPath' because its listed in containers exclusions list!", self::LOGLEVEL_DEBUG); - continue; + if (in_array($hostPath, $containerSettings['exclude'])) { + self::backupLog("Ignoring '$hostPath' because its listed in containers exclusions list!", self::LOGLEVEL_DEBUG); + continue; + } } if (!file_exists($hostPath)) { diff --git a/src/pages/content/settings.php b/src/pages/content/settings.php index ee7cb5e..208cbca 100644 --- a/src/pages/content/settings.php +++ b/src/pages/content/settings.php @@ -575,20 +575,20 @@ class="fa fa-clock-o title">Notifications and scheduling } $image = empty($container['Icon']) ? '/plugins/dynamix.docker.manager/images/question.png' : $container['Icon']; - $volumes = ABHelper::getContainerVolumes($container); + $volumes = ABHelper::getContainerVolumes($container, true); + $containerSetting = $abSettings->getContainerSpecificSettings($container['Name'], false); + $realContainerSetting = print_r($abSettings->getContainerSpecificSettings($container['Name']), true); if (empty($volumes)) { $volumes = "No volumes - container will NOT being backed up!"; } else { foreach ($volumes as $index => $volume) { - $volumes[$index] = ' ' . $volume . ''; + $excluded = in_array($volume, $containerSetting['exclude']) ? ' - EXCLUDED! ' : ''; + $volumes[$index] = ' ' . $volume . '' . $excluded . ''; } $volumes = implode('
', $volumes); } - $containerSetting = $abSettings->getContainerSpecificSettings($container['Name'], false); - $realContainerSetting = print_r($abSettings->getContainerSpecificSettings($container['Name']), true); - $containerExcludes = implode("\r\n", $containerSetting['exclude']); echo <<