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-serverbinary 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 INTOon 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 READtransaction, 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
- Start one Hub against the restored store with the normal credentials.
GET /api/v1/systemreturns the expected identity and HA role.GET /api/v1/jobsand/nodesshow the expected records; a dry-run job action succeeds.- Check the audit tail and one credential resolution (a managed token or a static operator token).
- Confirm the restored schema version is the one the running binary expects.
Disaster-recovery drill
Run this quarterly in a scratch environment:
- Take a fresh snapshot with
backup. - Restore it into an empty scratch store.
- Start a Hub with the scratch store and a throwaway operator token.
- Verify health/readiness, jobs, nodes, audit, and one read-only API call.
- 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
| Symptom | Cause | Fix |
|---|---|---|
snapshot file already exists | Target path exists | Choose a new path; never overwrite a snapshot. |
| Row-count verification failed | Store written during SQLite backup | Quiesce writes and retry. |
restore refuses the target | Target not empty | Use a fresh store or database. |
| PostgreSQL connection fails | Database absent/unreachable | Create the database and check credentials/network. |
| Restored Hub starts but jobs are missing | Wrong snapshot or partial copy | Re-run restore; verify with cp_* table counts. |