|
certbotbot
Reference documentation for a modular Bash project
|
Accepted
An explicitly enabled dated recovery copy will be published after successful publication of the current authoritative archive. DATED_BACKUP_ENABLED (CLI --dated-backup-enabled) is a literal Boolean, default false, resolved by CLI > exported environment > literal .env > default. Naming follows ADR-032: the same frozen UTC snapshot resolves the unchanged current key, default latest.tar.gz, and distinct backup key, default archive-{YEAR}{MONTH}{DOM}.tar.gz. For 2026-10-20 the backup name is archive-20261020.tar.gz. Configuring a backup template does not enable backups.
This decision narrowly supersedes ADR-028's prohibition of additional S3 objects, only for opt-in backup publication after current-state success. ADR-031's prohibition of an additional encrypted-mode object is similarly narrowed: current object identity, encrypted transport format, and the original migration safeguards remain unchanged. This design task #81 does not itself implement a second write. The destructive retention policy is reserved for task #84's independently reviewed Accepted ADR.
UPLOAD_NO_RENEWAL=true or the approved encryption migration requires a write..enc key renaming. A new encrypted backup does not meet ADR-031's separate pre-migration recovery-copy prerequisite.S3_KEY, and collision refusal.UPLOAD_NO_RENEWAL=true can force a validated publication even if Certbot made no durable change.This order makes "backup published but current failed" unreachable within one invocation. A failure in local Certbot, tar validation, GnuPG, preflight, naming, or private staging prevents both remote writes.
The chosen same-day policy is conditional replacement of a prior managed backup belonging to the same current-key identity and UTC date. An arbitrary object sharing a date-shaped name must never be overwritten on its appearance alone. In the initial S3 implementation, managed backup PutObject includes the following nonsecret S3 user metadata:
| Metadata key | Exact meaning |
|---|---|
certbotbot-backup-schema | Literal v1 |
certbotbot-utc-date | Frozen YYYYMMDD UTC date |
certbotbot-current-key-sha256 | Lowercase hex SHA-256 of the exact current key bytes |
certbotbot-archive-format | Literal tar.gz for the supported payload interior |
certbotbot-encryption | Literal none or gpg-ocb matching payload |
The current-key hash is a scope identifier, not a secret or a signed ownership proof. A principal authorized to write arbitrary S3 metadata may forge it. Restricting access to managed backup keys remains an operator responsibility and an explicit residual threat.
Preflight only the exact selected backup key. On confirmed absence, use aws s3api put-object --if-none-match "*", so another writer cannot quietly install a different object before creation. On existence, accept replacement only when all managed metadata match schema, date, current-key identity, archive format and encryption mode. Capture the existing ETag and use aws s3api put-object --if-match ETAG for an atomic key-level precondition. ETag is a conditional identity token, not an SHA-256 checksum. A nonmatching ETag, ambiguous S3 error, unsupported conditional operation, unrecognized historical metadata, inconsistent format/encryption or changed template means failure; never fall back to unconditional overwrite.
The accepted backup PutObject uses --checksum-algorithm SHA256, matching content type and user metadata. Afterwards an exact-key HeadObject must confirm the required metadata and nonzero expected payload size. If it fails, the backup is unverified and cannot authorize later retention. This is not an independent full-download integrity proof, complete remote durability proof, or cross-object atomic commit. S3 conditional headers protect a single key at a time, and ETag plus metadata cannot authenticate the archive body. No retry may turn a lost-response failure into an unconditional overwrite. S3 Versioning, if independently enabled, may retain previous same-day versions; certbotbot does not enable or manage it.
A changed template or explicit current key may create another current-key identity or backup namespace. This design does not silently adopt, rename, overwrite or enumerate former backup objects. Task #84 must define retention eligibility independently before any deletion code is written.
| Situation | Current | Dated backup | Command result |
|---|---|---|---|
| Backup disabled; no-op | Skip | Skip | Existing successful no-op |
| Backup disabled; upload needed | Existing PutObject policy | Never | Existing outcome |
| Enabled; no-op without forced write | Skip | Skip | Success; no new backup |
| Unsafe candidate/key or definite unknown backup collision | No PutObject | No PutObject | Prepublication failure |
| Current PutObject fails or has lost response | Failed/uncertain | Not attempted | Nonzero current failure |
| Current accepted, backup PutObject fails/conflicts | Accepted | Failed/uncertain | Nonzero partial success |
| Current accepted, backup Put accepted but HeadObject fails | Accepted | Unverified | Nonzero partial success; no retention |
| Current accepted, backup Put and Head verified | Accepted | Confirmed within stated checks | Success |
Static, nonsecret diagnostics must distinguish a current transfer failure from a partial success caused by the backup. Never echo raw AWS output, candidate filenames from private staging, GnuPG secrets, certificate contents, or credentials. The exact implementation return variable names and stdout presentation belong to #82, but they must faithfully express skipped/accepted/unverified outcomes; not claim a two-object transaction.
A dated object is a candidate for manual recovery, not the next normal restore target. The operator must identify and download the exact recovery key into an independently owned, private workspace, retain the object as evidence, authenticate/decrypt it where required, and validate its archive, ACME account and every lineage before accepting it as recovery state. The operator must separately back up newer current state, coordinate writers, and explicitly authorize any later replacement of the current key. Do not recommend invoking normal, write-capable certbotbot with a backup key as --s3-key as a read-only recovery command; that could overwrite the backup itself. No automatic restoration, rollback, backup key auto-discovery, scheduler, plaintext fallback, account creation, IAM provisioning or key recovery is part of this story.
Unconditional overwrite of same-day key: rejected: a matching basename might contain unrelated data. Exact managed metadata and S3 conditional writes reduce accidental replacement without pretending metadata is signed.
Reject every second run on one date: rejected: later successful renewal would be unable to update the same day's recovery point. The consequence of conditional replacement is possible loss of earlier same-day state unless the operator configured S3 Versioning.
Timestamp/random suffix for every run: rejected: the product's documented date-only default and retention identity would change.
Publish backup before current: rejected: it could advertise future state when current publication subsequently fails.
Always back up successful unchanged no-ops: rejected: would silently introduce automatic snapshot behavior; the existing forced republish option remains explicit.
Copy current S3 object into backup: rejected: a copy could race with an external writer and need not match the locally validated payload. Reuse the original private candidate instead.
Implicitly switch current to a backup after failure: rejected: unverified remote state and unrelated historical certificates could be activated by inference.
Use ETag as an archive integrity digest: rejected. ETag does not generally equal the content SHA-256; the tool uses its existing local validation, S3 SHA256 transfer checksum, and separate post-write metadata confirmation.
Implement SFTP, ZIP, retention or general backup discovery here: rejected as outside the two-object S3/tar.gz publication scope; future adapters must prove equivalent naming and guarded writes or fail explicitly.
The new trusted authority is additional exact-key S3 HEAD/conditional PUT, not global bucket listing or deletion. Threats include unsafe filename interpretation, unknown same-day object overwrite, leakage of plaintext while encryption is enabled, state truncation, remote write uncertainty, stale rollback and misleading full-success reporting. Mitigations are ADR-032 preflight, complete state candidate validation, one payload reused for both PUTs, authenticated encryption, guarded exact-key object identity, stage-specific errors and explicit operator recovery steps.
Pinning libraries and verifying local data do not protect compromised AWS executables, stolen credentials, forged user metadata, wrong runner UTC date, uncoordinated writers, or remote state changes after HeadObject. This is not a two-object transaction or automatic cloud durability proof.
Task #82 must implement this design with actual supported AWS CLI conditional calls. Task #83 must verify both ordinary and encrypted publication, repeated UTC date, rollover, forced/no-op policy, clean-runner operator recovery, rejected unrelated keys, ambiguous failures, all three public executable flavors, Bash 4.3 and appropriate real-GnuPG tests. Mocked tests must not be represented as live S3/ACME validation. Task #84 then governs any future managed-backup deletion separately.