fix: read KEY_ENCRYPTION_KEY in archive-only verify; never leave a partial archive

This commit is contained in:
2026-09-07 14:45:36 +00:00
parent f1fffcf16c
commit bb45bf8093
5 changed files with 205 additions and 10 deletions
+6 -2
View File
@@ -31,7 +31,12 @@ func newVerifyCmd() *cobra.Command {
}
defer archive.Close()
opt := backup.VerifyOptions{Archive: archive}
// The key is read unconditionally. Archive-only mode — no MONGO_URI,
// which is what a scheduled check uses — must still compare the key
// in hand against the archive's fingerprint; leaving it unset there
// reported "KEY_ENCRYPTION_KEY is not set" for a key that was set
// and correct.
opt := backup.VerifyOptions{Archive: archive, KeyHex: keyFromEnv()}
// A database is optional here. resolveGlobals fails without a URI or
// without a resolvable database name, and either error is a signal to
@@ -45,7 +50,6 @@ func newVerifyCmd() *cobra.Command {
defer client.Disconnect(context.Background())
opt.Client = client
opt.Database = g.Database
opt.KeyHex = g.KeyHex
} else {
fmt.Fprintf(c.ErrOrStderr(),
"note: %v, so this checks the archive and the key only\n", gerr)