Skip to main content
Version: 0.7.x

Backup, restore, and disaster recovery

The Hub's durable state (nodes, jobs, versions, intents, operations, rollouts, audit, credentials) lives in one store: a SQLite file or a PostgreSQL database. arkflow-server backup and restore are offline commands that copy that store; they never contact a running Hub.

Use when: before an upgrade, before an HA topology change, on a schedule for disaster recovery, or when rebuilding a Hub from scratch.

Impact. Both commands are offline. For a consistent snapshot, stop writes to the store; backup against an actively written SQLite store can fail row-count verification and leaves no partial file behind. restore requires an empty target store and every Hub against it stopped.

Prerequisites​

  • The arkflow-server binary version that matches the store schema you are backing up (or newer, for reading; restore into an older binary is not supported).
  • Read access to the source store and write access to the snapshot path.
  • A PostgreSQL target database that already exists (the tool does not create it).

Backup​

# SQLite source
arkflow-server backup --from /var/lib/arkflow/hub.sqlite \
--to /backups/hub-$(date +%F).sqlite

# PostgreSQL source
arkflow-server backup --from postgres://user:pass@db/hub \
--to /backups/hub-$(date +%F).sqlite

The snapshot is always a SQLite database file, regardless of the source backend. The target file must not exist; the command refuses to overwrite.

Consistency semantics:

  • SQLite — VACUUM INTO on the storage actor's serialized connection: the captured row counts and the file copy share one lock window.
  • PostgreSQL — every table is read inside a single REPEATABLE READ transaction, so the snapshot reflects one point in time. The long read holds an MVCC snapshot; schedule backups off-peak.

Verify the snapshot before trusting it:

sqlite3 /backups/hub-2026-12-05.sqlite 'PRAGMA integrity_check;'
sqlite3 /backups/hub-2026-12-05.sqlite \
"SELECT name FROM sqlite_master WHERE type='table' AND name LIKE 'cp_%';"

Restore​

# Into SQLite
arkflow-server restore --from /backups/hub-2026-12-05.sqlite \
--to /var/lib/arkflow/hub-restored.sqlite

# Into PostgreSQL (database must exist and be empty)
arkflow-server restore --from /backups/hub-2026-12-05.sqlite \
--to postgres://user:pass@db/hub-restored

Rules:

  • Stop every Hub against the target first. Restore is not an online operation and does not coordinate with a running process.
  • The target must be empty. Restoring into a populated store is refused rather than merged.
  • Row counts are verified; a mismatch exits non-zero and must be treated as a failed restore.
  • Cross-backend restore is supported in both directions (SQLite snapshot → PostgreSQL, and PostgreSQL snapshot → SQLite).

Verification​

  1. Start one Hub against the restored store with the normal credentials.
  2. GET /api/v1/system returns the expected identity and HA role.
  3. GET /api/v1/jobs and /nodes show the expected records; a dry-run job action succeeds.
  4. Check the audit tail and one credential resolution (a managed token or a static operator token).
  5. Confirm the restored schema version is the one the running binary expects.

Disaster-recovery drill​

Run this quarterly in a scratch environment:

  1. Take a fresh snapshot with backup.
  2. Restore it into an empty scratch store.
  3. Start a Hub with the scratch store and a throwaway operator token.
  4. Verify health/readiness, jobs, nodes, audit, and one read-only API call.
  5. Record the time from restore start to verified Hub.

A drill that only checks the file exists is not a drill. The restore-and-start path is the part that fails in practice.

Rollback​

Backup/restore has no in-place rollback: the snapshot is immutable. To undo a restore, restore the previous snapshot into another empty store and point the Hub at it. Keep at least one snapshot from before every upgrade and HA topology change.

Failure modes​

SymptomCauseFix
snapshot file already existsTarget path existsChoose a new path; never overwrite a snapshot.
Row-count verification failedStore written during SQLite backupQuiesce writes and retry.
restore refuses the targetTarget not emptyUse a fresh store or database.
PostgreSQL connection failsDatabase absent/unreachableCreate the database and check credentials/network.
Restored Hub starts but jobs are missingWrong snapshot or partial copyRe-run restore; verify with cp_* table counts.