Skip to content

Operations: prove backup, restore, upgrade, and disaster recovery for self-hosted Orbit #394

Open

Description

@imshashank

Current status, September 22

Backup capture shipped in #444; guarded restore is being reviewed in #481. Restore still needs authenticated/TLS Redis handling, credential-safe errors and recovery from an interrupted restore. Encryption, retention and the previous-release destroy-and-restore drill remain later slices, so neither PR closes this issue.

Original requirements

Goal

Turn Orbit’s current backup advice into a reproducible, automated recovery contract covering Postgres, object storage, configuration, and release upgrades.

This is a sibling workstream under #388. It covers the remaining recovery and operator-documentation portions of DB-001, REL-001, REL-002, and DOC-001 in docs/open-source-readiness.md.

Current boundary

The current self-hosting guide says:

  • durable application state lives in Postgres and uploaded files live in object storage
  • Redis is disposable
  • managed Postgres providers may take automatic backups
  • a self-hoster should run pg_dump and restore it somewhere once

That is sound advice, but it is not yet a supported product contract. There is no upstream backup command, coordinated snapshot procedure, restore validator, scheduled recovery test, retention model, or proof that a database dump and object-store copy describe the same recoverable installation.

Recovery model

Document and enforce the data classes before writing scripts.

Durable and required

Regenerable or disposable

  • Redis fan-out and ephemeral coordination state
  • application images, which must be recoverable from immutable release digests
  • static assets contained in images
  • caches and temporary build/runtime files

Do not back up raw ephemeral access tokens merely because a directory exists. Define every included table/object/config value deliberately.

Deliverables

1. Upstream backup command

Provide one supported command or container entry point, for example:

orbit backup create

or a documented equivalent under scripts//deploy/.

It must:

  • verify the installation is on a supported migration state
  • record Orbit version, source revision, image digests, migration hashes, database version, and backup format version
  • create a consistent Postgres backup using a format suitable for verified restore
  • copy or snapshot the object-storage bucket in a way that preserves every object needed by application rows
  • include only the minimal configuration metadata needed to restore, never plaintext runtime secrets by default
  • produce a manifest containing file/object hashes and counts
  • write to an operator-selected destination
  • fail atomically from the operator’s perspective: an incomplete backup is marked incomplete and cannot be mistaken for restorable output
  • return nonzero when either database or object-store capture fails

If strict point-in-time consistency across Postgres and object storage cannot be guaranteed in the first release, document the bounded consistency model and implement reconciliation on restore. Do not call two unrelated copy commands a consistent snapshot without evidence.

2. Encryption and secret handling

Backups can contain sensitive customer content, password hashes, OAuth credentials, MCP grants, email addresses, and attachments.

The supported workflow must:

  • support encryption before data leaves the host
  • avoid placing encryption keys or database passwords in process arguments, logs, manifest files, or shell history
  • permit integration with an operator-managed secret source
  • document key rotation and recovery-key custody
  • distinguish encrypted backup archives from image signatures/provenance
  • never upload a backup to Noveum infrastructure without an explicit operator action

Credential-at-rest encryption remains tracked separately by SEC-015; backup encryption does not replace it.

3. Restore command

Provide a supported command or container entry point, for example:

orbit backup restore <manifest>

It must:

  • verify archive and object hashes before mutation
  • verify backup format and Orbit compatibility
  • refuse an unsupported downgrade or unknown future format
  • restore only into an explicitly selected target installation/database/bucket
  • require destructive confirmation bound to the target identity
  • prevent accidental restore into production when the operator intended a test environment
  • restore Postgres and object storage in a documented order
  • run migration compatibility checks after restore
  • reconcile missing, extra, or versioned objects according to a stated policy
  • leave the target unavailable/unready if validation fails
  • emit a machine-readable result without printing secrets

4. Restore validation

A restore is not successful merely because pg_restore exits zero.

Add an application-aware validator that checks at least:

  • migration ledger hashes and catalog drift
  • user, organization, membership, team, issue, project, doc, and attachment referential integrity
  • every referenced stored object exists and can be read with the expected size/type constraints
  • no object required by a live row is silently missing
  • installation/bootstrap state is internally consistent
  • authentication can load an existing account without creating a bootstrap window
  • MCP grants retain their workspace binding and revocation state
  • Redis starts empty without data loss
  • application health/readiness becomes green only after validation succeeds

5. Scheduled backups and retention

Provide a platform-neutral scheduling example and a retention command/policy.

Cover:

  • hourly/daily/weekly examples without assuming Vercel cron
  • retention by age and count
  • deletion of incomplete and expired backups
  • legal hold or operator pinning
  • destination quota/full-disk behavior
  • alerting on failed or stale backups
  • clock/time-zone handling
  • cleanup that cannot delete the newest known-good backup accidentally

Do not put a scheduler inside every web replica. Use one explicit job/command that external schedulers, Kubernetes CronJobs, systemd timers, or app platforms can invoke.

6. Continuous recovery drill

CI or a scheduled workflow must prove recovery, not only backup creation.

At least nightly or per release candidate:

  1. deploy the previous supported Orbit release
  2. create representative users, memberships, issues, comments, projects, docs, integrations, MCP grants, and file attachments through supported product/API paths
  3. create an encrypted backup
  4. destroy the test database and bucket
  5. restore into a blank environment
  6. start the candidate release and run required migrations
  7. verify all representative data and authorization boundaries
  8. verify attachments byte-for-byte
  9. verify revoked sessions/grants remain revoked
  10. verify two-browser realtime after Redis starts empty
  11. record backup size, restore duration, and the exact image/migration versions

The drill must fail loudly when any referenced object, database row, migration, or permission check differs.

7. Upgrade and recovery matrix

For every stable release, document and test:

  • fresh install
  • previous stable → current stable
  • backup on previous stable → restore on previous stable → upgrade
  • backup on previous stable → direct restore into current stable, if supported
  • interrupted migration and documented forward-repair
  • application rollback when no irreversible schema change occurred
  • explicit refusal when rollback is unsafe

Do not promise arbitrary-version restores. State the supported window and format-version policy.

8. Operator runbooks

Add tested runbooks for:

  • routine backup
  • routine restore into a test environment
  • complete host loss
  • database corruption
  • object-storage loss
  • leaked backup encryption key
  • failed migration
  • accidental workspace/user deletion where recovery is supported
  • region/provider migration
  • validation failure after restore

Every command shown in documentation should either run in CI or be generated from the same source as the tested command.

Acceptance criteria

  1. A blank self-hosted deployment can create a backup using only documented commands.
  2. The backup contains a versioned manifest with hashes and no raw secrets.
  3. The archive can be encrypted with operator-controlled keys.
  4. A target-identity guard prevents accidental destructive restore.
  5. A complete environment can be destroyed and recovered from backup.
  6. All application data and uploaded files survive byte-for-byte where applicable.
  7. Redis can be discarded and rebuilt without loss of durable state.
  8. Existing users can sign in after restore; no new first-owner bootstrap window opens.
  9. Workspace isolation, invitations, integrations, and MCP grant binding/revocation remain correct.
  10. The previous-supported-release recovery/upgrade matrix passes automatically.
  11. A deliberately corrupted database archive, object, manifest, hash, encryption key, and incompatible version each cause a safe failure.
  12. Documentation includes measured recovery time and storage-size examples from the automated drill, clearly labelled as examples rather than guarantees.

Likely files

  • new backup/restore commands under scripts/ or deploy/
  • production image entry points from Deployment: publish production images and a complete Compose stack #392
  • packages/db/src/migrate/ and drift/catalog verification
  • storage service/client code for object listing and verification
  • a versioned backup manifest schema under packages/shared
  • .github/workflows/ for scheduled recovery drills
  • docs/self-hosting.md
  • docs/configuration.md
  • new backup, restore, upgrade, and incident runbooks
  • SECURITY.md

Not part of this issue

  • Provider-native managed backup implementation for every cloud
  • Redis persistence as a durable application requirement
  • Restoring data that was never included in a verified backup
  • Credential-at-rest encryption for live integrations, tracked by SEC-015
  • General retention behavior inside the Orbit product, tracked by REL-001 where applicable

Review boundary

Split implementation into focused pull requests:

  1. backup manifest and Postgres/object capture
  2. guarded restore and application-aware validation
  3. scheduled retention and encrypted destination examples
  4. previous-release recovery/upgrade drill and operator runbooks

Do not change the stable self-hosting claim until an automated destroy-and-restore drill succeeds against a production-shaped deployment.

Activity

  1. self-assigned this
    on Sep 3, 2026
  2. added
    help wanted
    on Sep 3, 2026
  3. Pallavikumarimdb commented on Sep 5, 2026

    @Pallavikumarimdb
    Contributor

    @imshashank Can I work on this issue?

  4. imshashank commented on Sep 6, 2026

    @imshashank
    ContributorAuthor

    @Pallavikumarimdb Yes please go ahead. This is a big task so may take some time, if you want any help let me know.

    I would recommend planning this first and maybe sharing that plan. Or feel free to start as you may like.

  5. removed their assignment
    on Sep 7, 2026
  6. added
    area: database
    roadmap
    p1 high
    on Sep 7, 2026
  7. added
    size: extra large
    points: 13
    on Sep 7, 2026
  8. Pallavikumarimdb commented on Sep 7, 2026

    @Pallavikumarimdb
    Contributor

    @Pallavikumarimdb Yes please go ahead. This is a big task so may take some time, if you want any help let me know.

    I would recommend planning this first and maybe sharing that plan. Or feel free to start as you may like.

    Hi @imshashank,

    Thank you! I have put together a technical plan to prove backup, restore, upgrade, and disaster recovery for self-hosted Orbit, addressing DB-001, REL-001, REL-002, and DOC-001.

    To keep reviews fast, focused, and safe, I propose splitting this 13-point task into 4 consecutive pull requests matching the issue review boundaries:

    Proposed PR Breakdown:

    1. PR 1: Backup Manifest Schema, Database Dump, Object Capture, and Atomic Backup CLI

      • Manifest schema in @orbit/shared with format version, git SHA, image digests, migration ledger, database version, and S3 checksums.
      • Explicit non-secret configuration allowlist (no plaintext secrets stored).
      • Pre-flight migration/drift check before capture.
      • Consistent Postgres snapshot (pg_dump -Fc) and S3 object capture with a documented bounded-consistency model.
      • Atomic execution (.incomplete marker and nonzero exit code on failure).
      • CLI command: bun run backup:create under scripts/backup/create.ts.
    2. PR 2: Guarded Restore Engine, Format Compatibility, and Application-Aware Validator

      • Pre-mutation checksum and manifest verification (bun run backup:restore).
      • Downgrade prevention and format version compatibility guards.
      • Target-identity guard requiring explicit confirmation (--confirm-destructive-restore-target=<target>) to prevent accidental production overwrite.
      • Database restore and object store reconciliation.
      • Application-aware validator checking migration ledger, catalog drift, referential integrity (users, orgs, issues, docs, MCP grants), and byte-for-byte S3 attachment existence.
      • Target readiness gating: keeps /api/health unready (503) until validation succeeds; emits machine-readable JSON results without secrets.
    3. PR 3: Backup Encryption, Scheduled Retention, and Platform-Neutral Schedulers

      • Envelope encryption using AES-256-GCM with operator-managed keys, secret-source integration (env var, key file, or KMS helper), and clear distinction from container image signatures.
      • Retention and pruning CLI (bun run backup:prune) with age/count rules, stale cleanup, legal-hold pinning, destination quota handling, and protection for the newest good backup.
      • Neutral scheduling examples for Docker Compose, systemd timers, and Kubernetes CronJobs.
    4. PR 4: Continuous Recovery Drill in CI, 7-Scenario Upgrade Matrix, and 10 Operator Runbooks

      • Automated GitHub Actions recovery drill: spins up previous release, seeds data, backs up, destroys environment, restores into blank environment with empty Redis, upgrades to candidate release, validates byte-for-byte attachment integrity, verifies two-browser realtime, and records size/duration metrics.
      • Automated upgrade matrix covering all 7 scenarios (fresh install, previous->current, rollback refusal, interrupted migration forward-repair, etc.).
      • 10 tested operator runbooks under docs/runbooks/ and updated docs/self-hosting.md.

    Clarifying Questions:

    1. CLI Entrypoint & Packaging: Do you prefer backup/restore commands exposed as root package scripts (bun run backup:create, bun run backup:restore under scripts/backup/) or packaged under a dedicated CLI package/binary (e.g. @orbit/cli)?
    2. Encryption Scope in PR 3: Does "encrypted destination examples" in the issue description refer to shipping in-tool archive envelope encryption (AES-256-GCM), documenting bucket-level/destination server-side encryption (SSE-S3/KMS/encrypted volume), or both?
    3. Coordination with Deployment: publish production images and a complete Compose stack #392 & Deployment: secure first-owner bootstrap and portable initial authentication #393: Are there specific container entrypoint conventions from Deployment: publish production images and a complete Compose stack #392 (production images) or auth bootstrap records from Deployment: secure first-owner bootstrap and portable initial authentication #393 that you want PR 1 and PR 2 to align with?

    Please let me know if this breakdown and direction look good, and I will begin work on PR 1!

  9. added
    work in progress
    and removed
    help wanted
    on Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area: databasep1 highpoints: 13roadmapsize: extra largework in progress

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions