Skip to content

openregs backup

Back up and restore the two stores that are not a function of a commit.

Everything under a release tag rebuilds from its commit. Two stores do not: the raw snapshot object store, which holds the bytes a regulator actually served, and the feed service’s subscription database, which holds registrations somebody made at a moment. backup create writes an encrypted archive plus a plaintext inventory of content hashes; backup restore decrypts and checks the whole archive against that inventory BEFORE writing anything, rebuilds the store, and then re-reads every payload and re-hashes it. A damaged archive names the member it is damaged at and restores nothing. See docs/runbooks/disaster-recovery.md.

openregs backup [-h] <command> ...

Write an encrypted archive of a store, plus its hash inventory.

Copy one store into an encrypted archive. The snapshot store is read through the object-store interface, so the same command backs up a directory and an S3-compatible bucket; the subscription database is copied with SQLite’s own online backup API, so it can be taken while the feed service is serving. The archive is deterministic: the same store and the same passphrase produce the same bytes, so two backups can be compared.

openregs backup create [-h] --kind {snapshots,feed} [--store <path>] --out <archive>
[--inventory <path>] --key-file <path> [--root <path>]
Option
--kind <value>which store to back up: snapshots or feed (required, one of snapshots, feed)
--store <path>the store to back up; defaults to <state-dir>/snapshots for —kind snapshots and state/feed/subscriptions.sqlite for —kind feed
--out <archive>where to write the encrypted archive (required)
--inventory <path>where to write the hash inventory; defaults to <archive>.inventory.json
--key-file <path>a file holding the archive passphrase. A file rather than a flag, so the passphrase stays out of the shell history and the process table (required)
--root <path>repository root

Rebuild a store from an archive, verifying every payload against the inventory.

Decrypt an archive and put the store back. Nothing is written until every member has decrypted, hashed and matched the inventory, so a damaged archive leaves the target exactly as it was and names the member it is damaged at. Once the objects are written they are read back out of the store and re-hashed against the inventory, so what is reported is what the store now holds.

openregs backup restore [-h] --archive <path> --into <path> [--inventory <path>] --key-file
<path> [--force]
Option
--archive <path>the encrypted archive to restore from (required)
--into <path>where the store goes: the object-store root for a snapshot archive, the database file for a feed archive (required)
--inventory <path>the hash inventory to check against; defaults to <archive>.inventory.json
--key-file <path>a file holding the archive passphrase. A file rather than a flag, so the passphrase stays out of the shell history and the process table (required)
--forcereplace a subscription database that is already at —into. Refused by default: it would discard every registration taken since the backup

Rendered from openregs/openregs@cbe9615:tooling/openregs/cli/main.py