Skip to content

Commit

Permalink
Ignore nested volumes - only backup parent then
Browse files Browse the repository at this point in the history
  • Loading branch information
Commifreak committed Apr 21, 2023
1 parent eaba3dc commit c94c083
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/include/ABHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit c94c083

Please sign in to comment.