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.
- 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.
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, orgcloud) 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).
-
Look up your subscription ID and the Microsoft Entra object ID for your user or VM managed identity:
Replace
RESOURCE_GROUPwith your Azure resource group name andVM_NAMEwith your Azure VM name (only if assigning a VM’s managed identity). -
Create the storage account with shared-key access disabled:
Replace
ACCOUNT_NAMEwith a globally unique storage account name (3–24 lowercase letters and digits),RESOURCE_GROUPwith your resource group name, andREGIONwith an Azure region close to your machines (such aseastus2). Optional: If your organization’s policy requires a storage firewall, add--default-action Denytoaz storage account create, then allow your machine’s IP address or VM subnet withaz storage account network-rule add --account-name ACCOUNT_NAME --resource-group RESOURCE_GROUP --ip-address CLIENT_IP(replacingCLIENT_IPwith your outbound IP address, or pass--subnet SUBNET_ID). -
Create the
atomic-snapshotscontainer through Azure Resource Manager (container-rmrequires no data-plane roles beforehand): -
Grant Storage Blob Data Contributor scoped to that container:
-
Install Azure sign-in support (not needed when you use a host-rotated SAS credential file):
-
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:IfHTTPS_PROXYis set on an Azure VM using Managed Identity, add the Instance Metadata Service address toNO_PROXY(NO_PROXY=169.254.169.254, plus any private identity endpoint) so Managed Identity token requests bypass the proxy. -
Turn snapshots on and verify read and write access:
Confirm that
atomic snapshots status --checkprintsCheck: okand exits0.
Configure Amazon S3
Amazon S3 turns on AES-256 server-side encryption (SSE-S3) by default for every bucket.-
Create a bucket and attach the following minimal Identity and Access Management (IAM) policy scoped to your prefix (
atomic-snapshots/*).s3:AbortMultipartUploadands3:ListMultipartUploadPartslet Atomic clean up interrupted multipart uploads:ReplaceBUCKET_NAMEwith your S3 bucket name. Optional: For an operator identity that runsatomic snapshots collect, attach a policy that addss3:DeleteObjecton the prefix ands3:ListBucketrestricted to the prefix: -
Install AWS sign-in support (not needed when you use a host-rotated credential file or
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYdirectly): -
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):ReplacePROFILE_NAMEwith your AWS CLI profile name andAWS_REGION_CODEwith your bucket’s region, such asus-east-1. -
Turn snapshots on and verify connectivity:
Confirm that
atomic snapshots status --checkprintsCheck: okand exits0.
Configure S3-compatible stores
Use ans3://BUCKET_NAME/PREFIX URL together with snapshots.s3 endpoint settings in ~/.atomic/agent/settings.json (or AWS_ENDPOINT_URL_S3).
- Cloudflare R2
- Backblaze B2
- MinIO
-
Set the endpoint and
"region": "auto"in~/.atomic/agent/settings.json:ReplaceBUCKET_NAMEwith your R2 bucket name andACCOUNT_IDwith your Cloudflare account ID. -
Export your R2 S3 API token with
AWS_ACCESS_KEY_IDandAWS_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.-
Create the bucket with uniform bucket-level access:
Replace
BUCKET_NAMEwith your Google Cloud Storage bucket name. -
Grant
roles/storage.objectUser(orroles/storage.objectAdminfor machines that runatomic snapshots collect) scoped with an IAM condition to your prefix:ReplaceSERVICE_ACCOUNT_EMAILwith the service account email address. -
Install Google Cloud sign-in support (not needed when you use a host-rotated downscoped token file):
-
Optional: If you aren’t using Workload Identity Federation, an attached service account, or
GOOGLE_APPLICATION_CREDENTIALS, sign in with Application Default Credentials (ADC): -
Turn snapshots on and verify connectivity:
Confirm that
atomic snapshots status --checkprintsCheck: okand exits0.
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:
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):- RPC (
set_snapshots) - SDK (
createAgentSession({ snapshots })) - CLI flag (
--snapshotsor--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) - 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) - Project settings (
.atomic/settings.json, only in a trusted project) - Global settings (
~/.atomic/agent/settings.json) - Default (snapshots off, no storage set)
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.
- settings.json
- CLI
- Environment
- TypeScript SDK
- RPC
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
SetATOMIC_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 SDKsnapshots.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 SDKsnapshots.baseCredentialFile/snapshots.baseCredential.
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 withhead-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
Whensnapshots.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, opaquewriterId(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/, andlocks/. - 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.
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 withATOMIC_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:
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-credential401or403, Atomic rereads once and retries the request once. - Immediate withdrawal: If the host deletes the credential file, Atomic fails immediately with
credentials-missingand 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 callslist,delete, container creation, or account APIs on the hot path. - Minimal health check:
atomic snapshots status --checkwrites and reads back one fixed.atomic-probeobject under the prefix (nolist, nodelete) and reports which permission is missing if it fails. - Shared-worktree chains: Set
snapshots.chain,ATOMIC_SNAPSHOTS_CHAIN, or--snapshots-chainwhen 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 receiveschain-conflict.
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):
-
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 a0600file, so check withls -lethat the file has none, and remove any withchmod -N: -
Point
snapshots.encryptionat the key file in~/.atomic/agent/settings.json(or pass the base64 or hex 32-byte key inATOMIC_SNAPSHOTS_ENCRYPTION_KEY):ReplaceBUCKET_NAMEwith your bucket name andUSERNAMEwith your local username. SettingATOMIC_SNAPSHOTS_ENCRYPTION_KEYon its own turns client-side encryption on (aes-256-gcm), even with nosnapshots.encryptionsetting.
USERNAME: your local username.REPO_NAME: your worktree folder name.BUCKET_NAME: your S3 bucket name.KEY_BYTES: aUint8Arrayholding the 32-byte key read from your secret manager.
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 reportsinvalid-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.modeis missing or isn’t"aes-256-gcm"or"sse"."aes-256-gcm"is set with no key from the SDK,ATOMIC_SNAPSHOTS_ENCRYPTION_KEY, orsnapshots.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 thechmodorchownthat fixes it. - A key is set while the mode is
"sse", so the key would go unused.
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. PlacebaseCacheDiron the same reflink-capable filesystem assnapshots.imageDir. - Object read-through cache (
snapshots.cacheDir, default~/.atomic/agent/snapshot-cache, capsnapshots.cacheMaxBytes, default512 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 thansnapshots.cacheMaxBytesdownload through a temporary staging file without evicting cached entries. Setsnapshots.cacheMaxBytesto0to disable disk caching.
- 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
--graceunder1800seconds (including0, half the 3600-second default) requires--no-active-writers(SDKnoActiveWriters: true), an assertion by the caller that no snapshot save runs against this storage during collection (--dry-rundoesn’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 itsbases/BASE_ID.jsonmetadata object (replaceBASE_IDwith the base identifier). The nextcollectrun 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, orfake-gcs-server.
- Azurite (Azure Blob)
- MinIO (S3-compatible)
- fake-gcs-server (GCS)
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 collectperiodically (for example, daily or weekly) and setsnapshots.keepGenerationsif you want a cap on retained generations per chain. - Keep
snapshots.baseCacheDirandsnapshots.cacheDirenabled 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
- Save and restore worktree snapshots — how disk-image snapshots work, platform support, rollback, and fork workflows.
- Worktree snapshots reference — SDK functions, mount-helper protocol, RPC commands, and
SnapshotErrorcodes. - Settings — complete
snapshots.*reference. - CLI reference —
--snapshots*flags andatomic snapshotssubcommands. - Environment variables —
ATOMIC_SNAPSHOTS*and cloud credential variables.