Docs/Core concepts

Ledger export & import

Move retained ledger history without duplicating its authority.

Read as Markdown ↗
On this page

A portable ledger archive

Export retains ledger and record identities, contracts, original acceptance facts, attachment references and authorized file bytes. It excludes credentials, local pending contributions and account membership. Missing file bytes stay missing.

Import creates a read-only replica. Imported records and observations explicitly carry imported-unverified provenance: checksums verify archive integrity, not the authenticity of historical acceptance claims. Source policies are reference information; they do not grant access at the destination.

Export and resume

Select a connection as usual. Follow next until complete is true, saving each returned archive page. Export requires ledger.export, ledger.read, records.read and contracts.read; files.read and access.read control optional bytes and policy information. Source changes or expired continuation require a new export.

Export and resume · Shell
op-sys --output json ledgers export --ledger-id <ledger-id> --limit 100

Import into an empty destination

Import each page with the same operation ID. The CLI envelope contains the page in payload; save that value as page.json. Identical retries are safe. Records become visible only when the final page passes integrity checks. Existing ledgers cannot be overwritten by an import.

Import into an empty destination · Shell
op-sys --output json ledgers import --bundle @page.json --operation-id restore-1

The same capability in every interface

Python uses client.ledgers.export and client.ledgers.import_. MCP uses op_sys_ledgers_export and op_sys_ledgers_import. HTTP exposes GET /v1/ledgers/{ledger_id}/export and POST /v1/ledger-imports with bundle and operation_id. HTTP receives JSON, never a path on the service host.

Pages contain at most 100 items, files use 64 KiB chunks, and an import is bounded to one million items and 192 MiB of encoded pages. This is ledger portability; full state-root recovery has a separate scope.