feat(backup): account-level backup and restore behind the Backup add-on (BUNYIP-353) #356
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/BUNYIP-353-account-backup-restore"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Backs the seeded "Backup" add-on tile with an account-level Backup and Restore surface (BUNYIP-353). A backup captures the account's Bunyip-side state (owner profile + entitled app slugs) plus a per-app section for each entitled app, as one JSON bundle the admin downloads; restore re-applies the profile, re-grants the listed entitlements, and dispatches each app's bundle to that app, gated on entitlement.
Reality-check that shaped the design
The ticket assumed bunyip relays a backup call to each app backend. It does not: bunyip is the OIDC issuer, apps are relying parties, and the only outbound-to-app path is the fire-and-forget webhook push (which cannot return a bundle). Mokosh's tenant-scoped backup API is also not shipped yet. So per-app backup/restore is expressed behind a pluggable
AppBackupAdaptertrait: the account orchestration is built and tested now, and the real Mokosh HTTP client drops intoMokoshBackupAdapter(currently a pending stub that reports "unavailable") once its endpoint exists. New adapters register in one place and never touch the orchestration.What's in it
crates/bunyip-domain/src/services/backup.rs): theAccountBackupbundle format (format_version1),AppBackupAdapter+AppBackupOutcome, theMokoshBackupAdapterpending stub, anAccountBackupStoredata seam (PgAccountBackupStoreover the existing user/entitlement/application repos) so the round-trip is unit-tested with no Postgres, andBackupServicewithcreate_backup/restore_backupreturning aRestoreReport.GET /v1/account/backupstreams the bundle as a download;POST /v1/account/restoreapplies an uploaded bundle and returns the report. BothAdminUser-gated and audited (AccountBackupCreated/AccountRestored, logginguser_id+ counts, never PII per BUNYIP-265)./integrations/backup(admin-guarded), linked from the Backup add-on tile on/applications, with a one-click download and a multipart restore upload that renders the resulting report.Decisions / scope
adminsource (theapplication_entitlements.sourceCHECK allowsadmin/stripe/backfill), so no migration is needed. Email is left unchanged (its verified-change flow owns it)..sqlxregen (all data access is runtimequery_as; audit actions are strings).Tests
Five pure domain tests (run in the standard container check, no DB): the backup->restore round-trip with Mokosh wired, entitlement gating both directions, the Mokosh-unavailable case, no-adapter skip, and format-version rejection.
just check-containeris green (fmt + clippy-D warnings+ full suite: domain 271 passed, web 94 passed).Follow-ups (out of scope)
MokoshBackupAdapter).🤖 Generated with Claude Code