From c94c08387f9c7f25983af9f3f5c03f58aa7f566b Mon Sep 17 00:00:00 2001 From: Robin Kluth Date: Fri, 21 Apr 2023 10:38:50 +0200 Subject: [PATCH] Ignore nested volumes - only backup parent then --- src/include/ABHelper.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/include/ABHelper.php b/src/include/ABHelper.php index 5d41a68..026aace 100644 --- a/src/include/ABHelper.php +++ b/src/include/ABHelper.php @@ -430,6 +430,23 @@ public static function getContainerVolumes($container) { } $volumes[] = rtrim($hostPath, '/'); } + + usort($volumes, function ($a, $b) { + return strlen($a) <=> strlen($b); + }); + self::backupLog("usorted volumes: " . print_r($volumes, true), self::LOGLEVEL_DEBUG); + + /** + * Check volumes against nesting + */ + foreach ($volumes as $volume) { + foreach ($volumes as $key2 => $volume2) { + if (str_starts_with($volume2, $volume) && $volume !== $volume2) { + self::backupLog("'$volume2' is within mapped volume '$volume'! Ignoring!", self::LOGLEVEL_WARN); + unset($volumes[$key2]); + } + } + } return $volumes; }