From 827e46381e3ec6478c5b0bf4489c46195a25f83a Mon Sep 17 00:00:00 2001 From: Dillard Blom Date: Wed, 21 Oct 2026 22:08:14 +0200 Subject: [PATCH] Log a snapshot that cannot be adopted when a location is added; full-restore test prints what target:add and backup:list said when the snapshot is missing --- lib/Service/TargetService.php | 3 ++- tests/integration/full-restore-roundtrip.sh | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/Service/TargetService.php b/lib/Service/TargetService.php index abb8989..4fd4922 100644 --- a/lib/Service/TargetService.php +++ b/lib/Service/TargetService.php @@ -228,7 +228,8 @@ final class TargetService { $s->setFiles((int)($meta['stats']['files'] ?? 0)); $s->setBytes((int)($meta['stats']['bytes'] ?? 0)); $this->snapshots->insert($s); - } catch (\Throwable) { + } catch (\Throwable $e) { + Server::get(\Psr\Log\LoggerInterface::class)->warning('NG Backup: snapshot ' . $snapshotId . ' on ' . $target->getName() . ' not listed: ' . $e->getMessage(), ['exception' => $e]); } } } diff --git a/tests/integration/full-restore-roundtrip.sh b/tests/integration/full-restore-roundtrip.sh index 10a1751..13bcb28 100755 --- a/tests/integration/full-restore-roundtrip.sh +++ b/tests/integration/full-restore-roundtrip.sh @@ -146,8 +146,14 @@ docker cp /tmp/ngb-frt-pass ngb-frt-restore:/tmp/pass ok "fresh restore instance up" run_on ngb-frt-restore backup:key:import /tmp/kit.json --passphrase-file=/tmp/pass >/dev/null || fail "key import" -run_on ngb-frt-restore backup:target:add offsite "${LOCATION[@]}" --path=repo >/dev/null || fail "target add on the restore instance" -run_on ngb-frt-restore backup:list offsite | grep -q "$SNAP" || fail "the origin's snapshot is not listed after connecting the location" +ADD_OUT=$(run_on ngb-frt-restore backup:target:add offsite "${LOCATION[@]}" --path=repo 2>&1) || { printf '%s\n' "$ADD_OUT"; fail "target add on the restore instance"; } +LIST_OUT=$(run_on ngb-frt-restore backup:list offsite 2>&1) +printf '%s\n' "$LIST_OUT" | grep -q "$SNAP" || { + printf 'target:add said:\n%s\nbackup:list said:\n%s\n' "$ADD_OUT" "$LIST_OUT" + docker exec ngb-frt-restore sh -c 'grep -h ng_backup /var/www/html/data/nextcloud.log | tail -5' || true + docker exec ngb-frt-restore sh -c 'ls -la /mnt/shared/repo /mnt/shared/repo/snapshots' || true + fail "the origin's snapshot is not listed after connecting the location" +} ok "recovery kit imported, existing repository adopted, snapshot visible" RESTORE_OPTS=(--no-interaction --install-apps)