Brain Docs
Run

Getting it up

Run it locallyConfiguration

Operating it

ObservabilityBackups and recoverySecurityScaling and limits

Reference

Brain/Docs
✦ ASKBrain on GitHubDashboard
RunBackups and recovery

Backups and recovery

Snapshots are the backup story, the periodic worker captures only the HNSW graph, and restore is destructive in place — which artefact is a restore point and which is an optimisation.

PURPOSE

Brain is single-node with no replication, so node loss means restore from snapshot. That makes this page load-bearing.

The distinction that catches people

Snapshot
What it covers
Taken via the admin API
POST to the snapshots endpoint on the admin plane
Full backup / restore — this is your disaster-recovery artefact
Taken by the periodic worker
Every `snapshot_interval_sec`, 6 hours by default
The HNSW graph only — NOT a full bundle

The background snapshot worker is not a backup schedule. It captures the index so a restart doesn't have to rebuild it. If your DR plan is "the periodic snapshot has us covered", you do not have a DR plan. Drive full snapshots yourself, on your own cadence, and copy them off the node.

Taking one

Snapshots live on the admin plane, which binds loopback inside the container:

# Create — triggers a checkpoint, copies (or reflinks) the storage files,
# and records the snapshot's metadata.
docker exec brain curl -s -X POST \
  -H "Authorization: Bearer $BRAIN_ADMIN_TOKEN" \
  http://127.0.0.1:9092/v1/snapshots

# List
docker exec brain curl -s \
  -H "Authorization: Bearer $BRAIN_ADMIN_TOKEN" \
  http://127.0.0.1:9092/v1/snapshots

# Delete — a DELETE on the snapshot itself
docker exec brain curl -s -X DELETE \
  -H "Authorization: Bearer $BRAIN_ADMIN_TOKEN" \
  http://127.0.0.1:9092/v1/snapshots/<name>

A listing gives you each snapshot's name, shard, size_gb and created_at.

A snapshot on the same volume as the data protects you from corruption and mistakes, not from losing the node. Copy them off.

What the WAL does

Every operation is fsynced to a write-ahead log before it's acknowledged — that's one of the engine's non-negotiable invariants. Nothing returns success until it's durable.

[shard]
wal_segment_size_bytes = "64MiB"
wal_retention_segments = 16        # ≈1 GiB retained per shard

On restart, recovery replays from the last durable checkpoint rather than from the beginning, and replay is idempotent across repeated runs. So an ungraceful kill — power loss, OOM, SIGKILL — comes back with writes intact, including ones not yet in any snapshot.

The WAL is crash recovery. The snapshot is disaster recovery. They are not substitutes: the WAL is on the volume you just lost.

Restoring

Restore is its own admin route, and it acts in place:

docker exec brain curl -s -X POST \
  -H "Authorization: Bearer $BRAIN_ADMIN_TOKEN" \
  -d '{"confirm":true}' \
  http://127.0.0.1:9092/v1/snapshots/<name>/restore

Restore is destructive

It replaces the current data. That is why it is gated server-side and will not proceed without the confirmation field — but the gate is a typo guard, not an undo. Take a fresh snapshot before restoring an old one if the current state is worth anything.

Two more things to get right:

  • Match the version. Restore into the same Brain version the snapshot came from. On-disk formats change between pre-1.0 releases without compatibility shims.
  • Match the embedding model. Vectors were written by a specific model, and it's pinned per deployment. Restoring into a deployment configured with a different [embedder] model gives you an index whose vectors mean something else.

Recovery time is not free

A cold start replays the WAL and loads indexes into RAM. The larger the shard, the longer that is, and /readyz returns 503 throughout.

Don't restart a slow-starting node because it looks hung — you'll start recovery over. Watch the logs, and size your readiness and deployment timeouts against a measured cold start rather than a guess.

Deletion, retention, and what a snapshot still holds

Three different clocks get conflated here, so it is worth separating them.

OptionTypeDefault / Env
Soft forgettombstone, then reclaim after grace

The memory stops being readable and stops matching recall immediately. The data remains for a configurable grace period — 7 days by default — after which a maintenance worker reclaims the slot. Inside the window it is reversible: POST /v1/memories/{id}/restore on the admin plane un-tombstones it and replays the forget undo log, re-attaching the evidence the cascade stripped. After grace the undo rows are gone too, and the forget is irreversible.

Hard forget / retractbytes zeroed

forget with hard overwrites the stored text immediately. retract schedules it and returns the deadline as will_zero_at_unix_nanos — read that field, because it is the only place the deadline is reported.

Retracted-row GCoff by default

[workers.statement_reclaim] physically deletes retracted statement rows once a grace window elapses — 30 days when enabled. It is off unless an operator opts in, so retracted rows stay in storage, invisible to retrieval, until you turn it on.

A snapshot taken before any of those completes still contains the data.

Restoring can resurrect data you were obliged to destroy

If you are deleting for compliance, an older snapshot predating the deletion will bring it back on restore. Know your retention window, know which snapshots predate which deletions, and prune snapshots on the same schedule you promised to delete on.

One thing a snapshot never contains: a tenant's provider key. Brain holds a namespace-scoped grant; the broker tells it only which provider and model to use and applies the real key itself on the way upstream, so customer keys stay out of the WAL, the snapshot and this backup entirely.

Test it

The only backup that counts is one you have restored. Restore into a scratch deployment, run a recall you know the answer to, and check answer_kind is what you expect.

Put it in CI if you can. Discovering a backup is unusable during an incident is the expensive way to find out.

Was this page helpful?

Observability

Liveness and readiness on the metrics port, all 74 Prometheus series grouped by what they answer, structured JSON logs, and optional OTLP tracing.

Security

Auth is mandatory and fail-closed, identity is never client-claimed, the planes can be split so provider keys never touch the memory process — and what remains yours.

On this page

The distinction that catches peopleTaking oneWhat the WAL doesRestoringRecovery time is not freeDeletion, retention, and what a snapshot still holdsTest it
Suggest an editOpen in Playground