From a7691223fd34bf8afe91009cb8e67e7705efde57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 25 Oct 2026 17:30:29 +0100 Subject: [PATCH] fix(db-backup): keep instances apart in a shared bucket, and no decrypted dump behind Off-host dumps were named by their time alone. Two instances sharing a bucket (nothing forbids it, and it was safe for the account objects) overwrote each other's dump at the same second of the same default schedule, and latest --from-bucket restored whichever instance's dump was newest. Each instance now uploads under database//, the object key (and so the encryption's associated data) carries it, and the restore takes only this instance's dumps: it refuses another's and names the instances it found, unless --instance= or the dump's full key says which one on purpose. A restore killed outright (out of memory, docker kill) left its .restore- or .download- directory, a whole database decrypted, in the backups directory, where nothing removed it. A restore now removes them before it starts and on SIGINT and SIGTERM, and the nightly retention sweeps any older than twelve hours. --- docs/ops/backup-restore.md | 5 +- docs/ops/disaster-recovery.md | 24 ++- scripts/__tests__/db-restore.test.ts | 53 +++++ scripts/compose-dr-drill.sh | 5 +- scripts/db-restore.mjs | 198 +++++++++++++---- .../__tests__/dump-core.test.ts | 77 +++++++ src/lib/database-backup/dump-core.mjs | 202 +++++++++++++++--- src/lib/database-backup/run.ts | 21 +- 8 files changed, 493 insertions(+), 92 deletions(-) diff --git a/docs/ops/backup-restore.md b/docs/ops/backup-restore.md index 6794929f2..2b57bb9cb 100644 --- a/docs/ops/backup-restore.md +++ b/docs/ops/backup-restore.md @@ -113,8 +113,9 @@ gzipped and sealed with AES-256-GCM under `BACKUP_ENCRYPTION_KEY`, with the object's own name as associated data and the key's id in the header. The nightly database dump goes into the same bucket, as -`database/healthlog-