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
- export
- import
Python API Reference
The same surface exists on the store and as thin gateway helpers.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.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.Best Practices
Keep reset_live_fields=True unless you know why not
Keep reset_live_fields=True unless you know why not
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.Cap ingest for untrusted payloads
Cap ingest for untrusted payloads
--max-sessions (default 10_000) bounds how many sessions land. The remainder is skipped and reported — never silently truncated.Always inspect ImportReport.skipped
Always inspect ImportReport.skipped
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.Prefer --out over stdout redirection
Prefer --out over stdout redirection
--out writes atomically via a temp file + os.replace, so a crashed export never leaves a half-written backup.Mind payload version compatibility
Mind payload version compatibility
PORTABLE_VERSION = 1. Older/unversioned payloads are accepted best-effort; a payload with a newer version is rejected wholesale rather than partially applied.Related
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.

