Skip to main content
Export gateway conversations to a portable JSON file so you can back them up, move them between hosts, or restore them after disaster.

Quick Start

1

Back up and restore from the CLI

Export every session to one file, then restore it on any host.
2

Do it from Python

The gateway helpers wrap the same store the gateway runs on.

How It Works

Export reads live sessions into a versioned payload; import writes them back and resets live routing fields so restored state stays inert until the gateway re-binds it.

Choosing the right options

Pick a scope, decide on lineage, and choose whether to overwrite.

CLI Reference


Python API Reference

The same surface exists on the store and as thin gateway helpers.
Gateway helpers target the store the gateway actually runs on:
DefaultSessionStore and SqliteSessionStore both implement PortableSessionStoreProtocol. ImportReport is JSON-serialisable via as_dict():

Payload format

The envelope is versioned and symmetric across the built-in stores.
Each session dict is the SessionData.to_dict() shape, so SessionData.from_dict() reconstructs it verbatim on import.

Common Patterns

Daily backup — schedule a cron job that writes one dated file per day.
Staging → production migration — export from staging, then overwrite only the ids being cut over.
Move one user’s conversation between hosts — export a single lineage-aware session, plain-import on the new host.
Restore after disaster — import a backup; live fields reset by default, so sessions stay inert until the gateway re-binds them.

Best Practices

Resetting clears gateway_session_id and agent_id (top-level and inside metadata) so a restored session cannot masquerade as an active connection. Only opt out with --keep-live-fields when re-importing onto the exact same live gateway.
--max-sessions (default 10_000) bounds how many sessions land. The remainder is skipped and reported — never silently truncated.
A skipped record — already-exists, malformed, or over the cap — is listed with a reason, never dropped in silence. Read skipped before assuming a clean restore.
--out writes atomically via a temp file + os.replace, so a crashed export never leaves a half-written backup.
PORTABLE_VERSION = 1. Older/unversioned payloads are accepted best-effort; a payload with a newer version is rejected wholesale rather than partially applied.

Session Persistence

Durability across restarts on the same host.

Session Continuity

Survive disconnects without losing in-flight state.

Session Store

Where and how gateway sessions are stored.

Session Protocol

The pluggable store contract, including portability.