Files
BortStack/docs/BACKUP_RESTORE.md

58 lines
3.5 KiB
Markdown

# Backup and Restore Decision
- Status: Deferred from the generic template
- Date: 2026-08-28
## Decision
Do not ship an executable database backup/upload/scheduling system in the generic template. Every generated production application must define and validate its own backup and restore contract before launch.
The template's supported database is MySQL in Docker Compose, but that does not establish the storage provider, jurisdiction, recovery-point objective (RPO), recovery-time objective (RTO), retention, immutability, encryption-key custody, scheduling platform, alert destination, database scale, or operator model required for a safe reusable implementation.
## Reference evidence
The reviewed RouletteBuddy implementation demonstrates a strong application-specific pattern:
- consistent logical MySQL dumps;
- encryption with an offline-controlled age identity;
- a write-only, bucket/prefix-restricted Backblaze B2 production credential;
- encrypted-object and plaintext-dump checksums;
- a content-limited manifest tied to an application commit;
- a non-root, read-only, capability-dropped one-shot container;
- serialized systemd execution, failure notification, immutable images, retention policy, and isolated restore drills.
Those are useful design inputs, not a provider-neutral implementation. The reference contains application names, server paths, provider APIs, retention/RPO/RTO choices, image digests, notification assumptions, and database-version constraints that must not be copied blindly.
## Required generated-project decision
Before production, each generated project must record:
- data classification, residency, and regulatory constraints;
- database engine/version and expected dump/restore size;
- RPO, RTO, retention, immutability, and deletion requirements;
- encrypted backup destination and least-privilege credential model;
- encryption algorithm and separate private-key custody/recovery;
- schedule owner, locking, monitoring, alerting, and missed-run detection;
- exact restore target and a refusal to overwrite production by default;
- restore verification checks and drill frequency;
- credential, encryption-key, image, and provider-incident rotation procedures.
## Minimum acceptance criteria for a future implementation
If a generated project elects to implement this pattern, it should not be called operational until:
1. Plaintext exists only in bounded temporary storage and is removed on every exit path.
2. Only encrypted objects and content-limited metadata leave the database host/network.
3. Production upload credentials cannot read, delete, manage buckets, or escape the application prefix unless an explicit documented constraint makes that impossible.
4. Encryption private keys are absent from production and backed up separately.
5. Archives and decrypted dumps have verified checksums.
6. Backup images and database clients are versioned and vulnerability-scanned.
7. A complete restore succeeds into disposable infrastructure using separately controlled read credentials.
8. The drill verifies schema/migration state and representative application behaviour within the stated RTO.
9. Scheduling, retention, alerts, and recovery steps are documented and monitored.
10. Restore tooling refuses an existing output/production target by default.
## Current operational warning
The template currently provides no database backup. A deployed generated application without a separately implemented and tested backup contract risks permanent data loss. Docker named volumes are persistence, not backup.