Skip to content
MembraneDocs
Search the documentation

Backup and restore

Protect warm-cache performance through node, volume, and regional failures. Membrane is a cache: every fragment can be recomputed by running prefill again, so backups protect performance, not correctness. Decide first whether a cold start after a disaster is acceptable; if it is, replicas alone are enough.

Recovery objectives

ApproachData loss on a node failureTime to a warm cache
Replicas only (default)None while a replica survivesImmediate; the replacement node refills from peers and traffic
Replicas plus --redis and --data-dirNone for the node’s own fragmentsMinutes; the node reloads its fragments on start
Plus scheduled snapshotsBack to the last snapshot, even if the cluster is lostTime to restore Redis and the volumes

What holds state

StateLocationNeeded to restore a node
Fragment metadataRedis (--redis), keys prefixed membrane:Yes
KV bytes<data-dir>/blobs on the node’s volume (--data-dir), AES-256-GCM encryptedYes
Data key<data-dir>/master.key, or the file given with --data-key-fileYes; without it the blobs are unreadable
API keys and TLS materialYour secret storeYes

Without --redis and --data-dir, a node keeps everything in memory and restarts empty, while its peers still hold their replicas.

On startup, a node with --redis reloads the fragments recorded for its node id. It keeps those that are metadata-only or whose bytes are still in its data directory, and drops the rest from its index.

Back up

Redis

Enable Redis persistence (AOF or RDB) and copy the dump off the host on a schedule:

Snapshot Redis
redis-cli -h "$REDIS_HOST" BGSAVE
# wait for LASTSAVE to change, then copy dump.rdb to object storage

Data directory

Snapshot each node’s volume. On Kubernetes these are the data-membrane-N PersistentVolumeClaims created by the StatefulSet; use VolumeSnapshot objects or your storage provider’s snapshots. Under Docker Compose, it is the membrane-data volume.

Data key

WARNING

If the data key was generated into the data directory, every volume snapshot contains it, so a snapshot must be protected like the key itself. In production, keep the key in a secret manager and mount it with --data-key-file (MEMBRANE_DATA_KEY_FILE).

Restore

  1. Stop the nodes:

    Terminal window
    kubectl scale statefulset membrane --replicas=0
  2. Restore Redis from its dump, and wait for redis-cli ping to succeed.

  3. Restore each node’s data volume from its snapshot, matching the node id: membrane-0 gets data-membrane-0.

  4. Start the nodes. Each logs Restored N fragments for <node> from Redis.

  5. Verify with an admin key:

    Terminal window
    membrane client inventory --base-url https://membrane-0... --api-key "$ADMIN_KEY"

Disaster scenarios

ScenarioEffectRecovery
One node lostIts fragments are still on replicasReplace the pod; it rejoins and fills up again
Redis lost, volumes intactNodes start empty, with no metadata to reloadRestore Redis, or accept a cold cache
Volume lost, Redis intactFragments without bytes are skipped at startupNone needed; they are recomputed on demand
Data key lostBlobs are unreadable; /retrieve reports them as corruptDelete the data directory and start cold
Whole cluster lostCold cacheRedeploy; optionally restore Redis and volumes first