Skip to main content
Use this guide if you’re a developer or host operator configuring external storage for Atomic worktree snapshots. By the end of this page, you can configure snapshot storage on any supported provider, optionally separate shared read-only prepared bases from per-session snapshots, rotate short-lived host credentials, configure encryption, and diagnose storage errors. This page covers snapshot storage configuration and troubleshooting. For how disk-image snapshots work, platform support, and rollback or fork workflows, see Save and restore worktree snapshots. For session conversation databases (SQLite, JSONL, or PostgreSQL), see Storage.

How snapshot storage separates from session storage

Session storage (SQLite or PostgreSQL) stores your conversations and a small pointer to each snapshot. Snapshot storage (snapshots.storage) stores prepared repository bases, chunked diffs, manifests, and chain heads. Snapshot data never goes into SQLite or PostgreSQL. Worktree snapshots are off by default on fresh installs and after upgrading from Atomic 0.10.x, and there is no implicit storage location. Snapshots are effectively on only when both of the following conditions hold:
  • You request snapshots on in settings.json, a CLI flag, an environment variable, the SDK, or RPC.
  • You configure a valid, supported snapshot storage URL with resolvable credentials.
If you request snapshots on without valid storage, Atomic writes no snapshot data anywhere (no local fallback, no temporary blobs, and nothing in the session database), prints one plain message naming how to configure storage on your surface (or turn snapshots off), and continues the session normally. If configured storage becomes unreachable or refuses access at save time, Atomic skips that save with one message, never falls back locally, and tries again on the next save. Supported snapshot storage locations include the following standard stores:
  • Azure Blob Storage, including Azure Data Lake Storage Gen2 (ADLS Gen2) accounts with a hierarchical namespace.
  • Amazon S3 and S3-compatible stores (MinIO, Cloudflare R2, and Backblaze B2).
  • Google Cloud Storage.
  • An explicit local directory (file://) for single-machine use.
Credentials never go in settings.json or in snapshots.storage or snapshots.baseStorage URLs. Atomic authenticates through each cloud’s standard credential chain or through a short-lived, prefix-scoped credential file rotated by a host.
Host-rotated credential files (Azure user-delegation Shared Access Signature (SAS), AWS session or presigned credentials, and Google Cloud downscoped tokens) and environment-key credentials work over plain HTTP with zero extra packages installed; ambient cloud sign-in chains install one optional package in the steps that follow.

Before you begin

Confirm the following prerequisites before configuring a provider:
  • Atomic 0.11.0 or later installed on every machine that saves or restores snapshots.
  • Permission to create a bucket, container, or local directory and assign a least-privilege role or policy.
  • Your cloud CLI installed (az, aws, or gcloud) if you plan to use the cloud’s ambient credential chain.

Configure a storage provider

Pick your provider, grant the least-privilege role or policy, sign in with your cloud identity, and turn snapshots on.

Configure Azure Blob Storage and ADLS Gen2

Atomic works with flat-namespace Azure Blob accounts and ADLS Gen2 accounts, including accounts with shared-key access disabled (--allow-shared-key-access false).
  1. Look up your subscription ID and the Microsoft Entra object ID for your user or VM managed identity:
    Replace RESOURCE_GROUP with your Azure resource group name and VM_NAME with your Azure VM name (only if assigning a VM’s managed identity).
  2. Create the storage account with shared-key access disabled:
    Replace ACCOUNT_NAME with a globally unique storage account name (3–24 lowercase letters and digits), RESOURCE_GROUP with your resource group name, and REGION with an Azure region close to your machines (such as eastus2). Optional: If your organization’s policy requires a storage firewall, add --default-action Deny to az storage account create, then allow your machine’s IP address or VM subnet with az storage account network-rule add --account-name ACCOUNT_NAME --resource-group RESOURCE_GROUP --ip-address CLIENT_IP (replacing CLIENT_IP with your outbound IP address, or pass --subnet SUBNET_ID).
  3. Create the atomic-snapshots container through Azure Resource Manager (container-rm requires no data-plane roles beforehand):
  4. Grant Storage Blob Data Contributor scoped to that container:
  5. Install Azure sign-in support (not needed when you use a host-rotated SAS credential file):
  6. Optional: If you aren’t running on a VM or container with Managed Identity, AKS Workload Identity, or AZURE_TENANT_ID / AZURE_CLIENT_ID / AZURE_CLIENT_SECRET, sign in with your Azure account:
    If HTTPS_PROXY is set on an Azure VM using Managed Identity, add the Instance Metadata Service address to NO_PROXY (NO_PROXY=169.254.169.254, plus any private identity endpoint) so Managed Identity token requests bypass the proxy.
  7. Turn snapshots on and verify read and write access:
    Confirm that atomic snapshots status --check prints Check: ok and exits 0.

Configure Amazon S3

Amazon S3 turns on AES-256 server-side encryption (SSE-S3) by default for every bucket.
  1. Create a bucket and attach the following minimal Identity and Access Management (IAM) policy scoped to your prefix (atomic-snapshots/*). s3:AbortMultipartUpload and s3:ListMultipartUploadParts let Atomic clean up interrupted multipart uploads:
    Replace BUCKET_NAME with your S3 bucket name. Optional: For an operator identity that runs atomic snapshots collect, attach a policy that adds s3:DeleteObject on the prefix and s3:ListBucket restricted to the prefix:
  2. Install AWS sign-in support (not needed when you use a host-rotated credential file or AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY directly):
  3. Optional: If you aren’t using an attached IAM role, IRSA, ECS task role, or EC2 IMDSv2, select your AWS profile and region (or sign in with aws sso login):
    Replace PROFILE_NAME with your AWS CLI profile name and AWS_REGION_CODE with your bucket’s region, such as us-east-1.
  4. Turn snapshots on and verify connectivity:
    Confirm that atomic snapshots status --check prints Check: ok and exits 0.

Configure S3-compatible stores

Use an s3://BUCKET_NAME/PREFIX URL together with snapshots.s3 endpoint settings in ~/.atomic/agent/settings.json (or AWS_ENDPOINT_URL_S3).
  1. Set the endpoint and "region": "auto" in ~/.atomic/agent/settings.json:
    Replace BUCKET_NAME with your R2 bucket name and ACCOUNT_ID with your Cloudflare account ID.
  2. Export your R2 S3 API token with AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (or configure a named profile in ~/.aws/credentials), then verify access:

Configure Google Cloud Storage

Google Cloud Storage turns on Google-managed AES-256 server-side encryption on every bucket by default.
  1. Create the bucket with uniform bucket-level access:
    Replace BUCKET_NAME with your Google Cloud Storage bucket name.
  2. Grant roles/storage.objectUser (or roles/storage.objectAdmin for machines that run atomic snapshots collect) scoped with an IAM condition to your prefix:
    Replace SERVICE_ACCOUNT_EMAIL with the service account email address.
  3. Install Google Cloud sign-in support (not needed when you use a host-rotated downscoped token file):
  4. Optional: If you aren’t using Workload Identity Federation, an attached service account, or GOOGLE_APPLICATION_CREDENTIALS, sign in with Application Default Credentials (ADC):
  5. Turn snapshots on and verify connectivity:
    Confirm that atomic snapshots status --check prints Check: ok and exits 0.

Configure a local directory (file://)

If you work on one machine and want snapshots stored locally without a cloud account, configure an explicit absolute directory path writable by your user:
On Windows, use file:///C:/Users/USERNAME/atomic-snapshots (replace USERNAME with your Windows user name). Avoid placing a local snapshot directory inside a cloud-synced folder or on a slow network share when an object store is available. Snapshot storage may live on a network share (an NFS or SMB mount used through file://); only snapshots.imageDir, where the active worktree images and their markers live, must be on a local disk.

Configure snapshot storage across every surface

Every surface reads the same settings using one precedence order (highest first):
  1. RPC (set_snapshots)
  2. SDK (createAgentSession({ snapshots }))
  3. CLI flag (--snapshots or --no-snapshots, --snapshots-storage URL, --snapshots-base-storage URL, --snapshots-credential-file PATH, --snapshots-base-credential-file PATH, --snapshots-chain CHAIN_ID, --snapshots-engine MODE)
  4. Environment variable (ATOMIC_SNAPSHOTS, ATOMIC_SNAPSHOTS_STORAGE, ATOMIC_SNAPSHOTS_BASE_STORAGE, ATOMIC_SNAPSHOTS_CREDENTIAL_FILE, ATOMIC_SNAPSHOTS_BASE_CREDENTIAL_FILE, ATOMIC_SNAPSHOTS_CHAIN, ATOMIC_SNAPSHOTS_ENGINE)
  5. Project settings (.atomic/settings.json, only in a trusted project)
  6. Global settings (~/.atomic/agent/settings.json)
  7. Default (snapshots off, no storage set)
Run atomic snapshots status at any time to see the requested state, the effective state (on or off), and which configuration layer set each value. In the following examples, replace ACCOUNT_NAME with your Azure storage account name and BUCKET_NAME with your S3 bucket name.
Add snapshots.on and snapshots.storage to ~/.atomic/agent/settings.json (or .atomic/settings.json in a trusted project):

Isolate settings and issue per-prefix credentials on a host

A host that sleeps sessions and wakes them on fresh machines shouldn’t give a worker VM broad access to an entire bucket or container, and shouldn’t let untrusted files in a workspace redirect snapshot storage.

Restrict configuration sources

Set ATOMIC_SNAPSHOTS_SETTINGS_SOURCES=env,flags on host-launched processes so Atomic ignores project .atomic/settings.json and user ~/.atomic/agent/settings.json completely and reads only environment variables and CLI flags. Accepted comma-separated tokens are env, flags (or cli), sdk, rpc, project, and user (or global).

Share read-only prepared bases separately (snapshots.baseStorage)

Prepared repository bases are shared across sessions for the same repository and OS, while per-session diffs belong to one tenant or workspace prefix. To avoid duplicating prepared bases into every per-session prefix, configure a separate read-only base store:
  • URL: snapshots.baseStorage, ATOMIC_SNAPSHOTS_BASE_STORAGE, --base-storage URL / --snapshots-base-storage URL, or SDK snapshots.baseStorage.
  • Optional separate credential (host-only, forbidden in settings.json): ATOMIC_SNAPSHOTS_BASE_CREDENTIAL_FILE, --base-credential-file PATH / --snapshots-base-credential-file PATH, or SDK snapshots.baseCredentialFile / snapshots.baseCredential.
When snapshots.baseStorage is set, Atomic downloads and verifies prepared bases from baseStorage while writing session chunks, manifests, and chain heads to snapshots.storage. With client-side encryption enabled (snapshots.encryption.mode: "aes-256-gcm"), snapshots.baseStorage is read using the same encryption key as the snapshots—prepare its bases with that key, because sessions with different keys can’t share one base store (see What stays visible with client-side encryption).

Trust model for storage write access

Like other object-store snapshot tools (such as restic and kopia), snapshot storage has no separate trusted monotonic counter: anyone with write access to a snapshot storage location has full control of its snapshots, including rewriting a chain head to roll a fresh machine back to an earlier generation. A machine that already saved on that chain still detects the divergence and refuses its next save with head-advanced, but a fresh machine with no local history trusts the head stored in the prefix unless an external coordinator pins the expected generation or verifies signed expectations through --expect and snapshots.mountHelper. Follow these access boundaries:
  • Grant write access only to machines that save snapshots to that prefix.
  • Scope each machine’s write credential strictly to its own tenant or workspace prefix.
  • Use read-only credentials for shared prepared-base stores (snapshots.baseStorage).

What stays visible with client-side encryption

When snapshots.encryption.mode is "aes-256-gcm", Atomic encrypts snapshot data chunks, manifests, and prepared base descriptors (bases/BASE_ID.json) before uploading—and rejects plaintext base descriptors with no fallback. Chain heads (heads/CHAIN_ID.json) stay plaintext so cloud conditional compare-and-swap fencing works directly without a separate coordinator. As other encrypted object-store snapshot tools (such as restic and kopia) document, anyone who can read the storage location can still see:
  • Head metadata: Each chain head’s generation, opaque writerId (contains no hostname or username), snapshot and manifest IDs, SHA-256 hashes, base fingerprint, and timestamps.
  • Object keys: Prefix paths and object names under bases/, data/sha256/..., manifests/, heads/, and locks/.
  • Object sizes and timestamps: Byte lengths and last-modified times of stored objects.
  • Chain and generation structure: Which chains exist, how many generations each chain has, and when saves occur.
Client-side encryption applies only to objects stored in snapshot storage—not the local mounted worktree, active disk images (snapshots.imageDir), cached prepared base images (snapshots.baseCacheDir), or the local read-through object cache (snapshots.cacheDir, which stores plaintext verified objects). Protect the machine’s local storage with full-disk encryption and OS permissions (and set snapshots.cacheMaxBytes to 0 if you want to disable the local object cache). A separate base store (snapshots.baseStorage) is read with the same client-side encryption key as the snapshots, so prepare its bases with that key. Sessions with different keys can’t share one base store: a base prepared without client-side encryption, or with another key, is refused with a message directing you to re-prepare it with atomic snapshots base create (or use a base store prepared with that key), and is never read as plaintext.

Rotate prefix-scoped credential files

Pass the credential file path with ATOMIC_SNAPSHOTS_CREDENTIAL_FILE or --snapshots-credential-file PATH (never in settings.json). The host writes one JSON object atomically (write, fsync, rename) with an ISO-8601 UTC expiresAt. Azure SAS credential file:
AWS session credential file:
Google Cloud downscoped OAuth token file:
Replace ACCESS_KEY_ID, SECRET_ACCESS_KEY, SESSION_TOKEN, SIGNATURE, and OAUTH_ACCESS_TOKEN with the short-lived prefix-scoped values issued by your host. Atomic handles host-supplied credentials with these rules:
  • No silent widening: When a host credential is configured, Atomic disables the machine’s ambient cloud credential chain completely. Isolation between tenants comes from the cloud credential’s prefix scope.
  • Proactive rotation: Atomic rereads the file when within five minutes of expiresAt. If the cloud returns an expired-credential 401 or 403, Atomic rereads once and retries the request once.
  • Immediate withdrawal: If the host deletes the credential file, Atomic fails immediately with credentials-missing and doesn’t retry.
  • Least privilege on the hot path: Saving and restoring need only read, create, and write on keys under the prefix (for example, an Azure user-delegation SAS with sp=rcw). Atomic never calls list, delete, container creation, or account APIs on the hot path.
  • Minimal health check: atomic snapshots status --check writes and reads back one fixed .atomic-probe object under the prefix (no list, no delete) and reports which permission is missing if it fails.
  • Shared-worktree chains: Set snapshots.chain, ATOMIC_SNAPSHOTS_CHAIN, or --snapshots-chain when multiple sessions share one workspace. Atomic enforces single-writer fencing with conditional writes so two VMs waking the same chain can’t overwrite each other; the second writer receives chain-conflict.
Hosts embedding the SDK can also pass a credential: () => Promise<SnapshotCredential> callback (and baseCredential for baseStorage), or push a rotated credential over RPC with set_snapshots.

Configure encryption

Server-side encryption (SSE) is on by default on every cloud provider:
  • Azure Blob and ADLS Gen2: AES-256 Storage Service Encryption (optional custom scope with snapshots.azure.encryptionScope).
  • Amazon S3: SSE-S3 AES-256 (optional Key Management Service (KMS) key with snapshots.s3.kmsKeyId).
  • Google Cloud Storage: Google-managed AES-256 (optional Customer-Managed Encryption Key (CMEK) with snapshots.gcs.kmsKeyName).

Opt in to client-side encryption

To encrypt snapshot data chunks, manifests, and prepared base descriptors (bases/BASE_ID.json) before they leave the machine, opt in to AES-256-GCM client-side encryption (when enabled, Atomic rejects plaintext base descriptors with no fallback; chain heads remain plaintext—see What stays visible with client-side encryption):
  1. Generate a 256-bit key and save it with owner-only permissions. On Linux and macOS, Atomic reads the key file only when it’s a regular file you own with mode 0600, not a link. It checks the mode and owner, not ACLs: on macOS, an ACL can still let others read a 0600 file, so check with ls -le that the file has none, and remove any with chmod -N:
  2. Point snapshots.encryption at the key file in ~/.atomic/agent/settings.json (or pass the base64 or hex 32-byte key in ATOMIC_SNAPSHOTS_ENCRYPTION_KEY):
    Replace BUCKET_NAME with your bucket name and USERNAME with your local username. Setting ATOMIC_SNAPSHOTS_ENCRYPTION_KEY on its own turns client-side encryption on (aes-256-gcm), even with no snapshots.encryption setting.
Hosts embedding the SDK pass the key’s 32 bytes directly instead of a file:
Replace the following:
  • USERNAME: your local username.
  • REPO_NAME: your worktree folder name.
  • BUCKET_NAME: your S3 bucket name.
  • KEY_BYTES: a Uint8Array holding the 32-byte key read from your secret manager.
RPC clients can’t send an encryption key: set_snapshots refuses an encryption field instead of ignoring it. Configure encryption with ATOMIC_SNAPSHOTS_ENCRYPTION_KEY, snapshots.encryption in settings.json, or the SDK before the session starts.

Encryption that can’t be applied stops the save

When client-side encryption is requested and Atomic can’t apply it, Atomic stores nothing and reports invalid-setting naming the setting. It never falls back to unencrypted storage. Each of these stops the save before anything is mounted or written:
  • snapshots.encryption.mode is missing or isn’t "aes-256-gcm" or "sse".
  • "aes-256-gcm" is set with no key from the SDK, ATOMIC_SNAPSHOTS_ENCRYPTION_KEY, or snapshots.encryption.keyFile.
  • The key doesn’t decode to exactly 32 bytes, or the key file can’t be read.
  • On Linux and macOS, the key file is a symbolic link, isn’t a regular file, has a mode other than 0600, or is owned by another user. The message names the file and the chmod or chown that fixes it.
  • A key is set while the mode is "sse", so the key would go unused.
A store whose base descriptors or snapshots were written without client-side encryption can’t be read with it: Atomic refuses those plaintext objects with no fallback. Use a new storage prefix when you turn client-side encryption on. See What stays visible with client-side encryption for what remains readable in storage and on local disk.
If you lose the client-side encryption key, existing encrypted snapshots can’t be decrypted. Back up the key in a secret manager before enabling aes-256-gcm.

Manage the local cache and run garbage collection

For cloud snapshot storage, Atomic maintains two local caches:
  • Prepared base cache (snapshots.baseCacheDir, default ~/.atomic/agent/snapshot-bases): Stores verified read-only (0444) sparse base images and stat stamps so wakes skip redownloading base images. Place baseCacheDir on the same reflink-capable filesystem as snapshots.imageDir.
  • Object read-through cache (snapshots.cacheDir, default ~/.atomic/agent/snapshot-cache, cap snapshots.cacheMaxBytes, default 512 MiB): Caches downloaded chunk objects per storage location (isolated by storage type, canonical URL, endpoint, and encryption key) after verifying their SHA-256 checksums. Objects larger than snapshots.cacheMaxBytes download through a temporary staging file without evicting cached entries. Set snapshots.cacheMaxBytes to 0 to disable disk caching.
To remove unreferenced data objects and superseded manifests from your bucket or container, run garbage collection from an operator identity with list and delete permissions on the prefix:
Garbage collection follows these safety rules:
  • Marks all live references: Collection scans all chain heads, every retained generation in each chain’s history, and every published prepared base (bases/BASE_ID.json), keeping every referenced chunk and compact base object alive.
  • Prunes superseded manifests: Collection removes superseded version-3 manifests past the grace window when their chain’s live head is newer, while preserving every active generation’s manifest.
  • Respects server clocks and the grace window: Object ages, re-stamps, and collection locks use the storage service’s clock, not the local machine’s clock. Passing --grace under 1800 seconds (including 0, half the 3600-second default) requires --no-active-writers (SDK noActiveWriters: true), an assertion by the caller that no snapshot save runs against this storage during collection (--dry-run doesn’t require --no-active-writers).
  • Retiring unused prepared bases: Because published bases in bases/ are kept live even before any snapshot uses them, retire an old prepared base by deleting its bases/BASE_ID.json metadata object (replace BASE_ID with the base identifier). The next collect run removes its compact data object after no manifest references it.

Stores that can’t refuse a stale delete

Garbage collection deletes snapshot data only when the storage can refuse to delete an object that a running save just reused. Where it can’t, atomic snapshots collect deletes nothing, prints Nothing was deleted. with the reason and the exact atomic snapshots collect ... --no-active-writers command repeating your options, and exits 3 so a scheduled job can tell this safe refusal from a failure (exit 1). When --grace is below 1800 seconds without --dry-run, it also deletes nothing and exits 1, naming --grace 1800 and the same command. Pass --no-active-writers (SDK noActiveWriters: true) only after stopping every writer saving snapshots to that storage. The following table shows which stores support collecting while sessions save: A host that sleeps sessions and wakes them on fresh machines runs collection while no machine is saving to that storage, and passes --no-active-writers only then. No setting or environment variable turns it on.

Test locally with an emulator

You can test cloud snapshot storage locally without a cloud account by running Azurite, MinIO, or fake-gcs-server.
Start Azurite, create the container, and verify access:

Cost estimates

Because snapshots store only changed 8 MiB chunks compressed with zstd and deduplicate identical content by SHA-256, storage usage stays proportional to changed blocks rather than full virtual disk sizes. The following table gives approximate monthly cloud storage footprints: Follow these practices to keep storage and transfer costs low:
  • Put snapshot storage in the same cloud region as your machines. Same-region transfers between VMs and object storage are free on Azure, AWS, and Google Cloud; cross-region or internet egress incurs per-GB transfer charges.
  • Run atomic snapshots collect periodically (for example, daily or weekly) and set snapshots.keepGenerations if you want a cap on retained generations per chain.
  • Keep snapshots.baseCacheDir and snapshots.cacheDir enabled so repeated wakes reuse verified local copies instead of redownloading objects.

Troubleshoot storage errors

Every snapshot storage failure returns a stable error code, describes what happened, and names the fix (with all credentials redacted). The following table lists every snapshot storage error code:

What’s next