Docs · how to

Snapshot and fork

Capture a running environment as a version, fork it per rollout, and roll back.

Fork from the current version

denv fork --name rollout-017 <env>

A fork is a new environment created from a version. Its name is yours; its parent is the version. On ZFS hosts it is a clone and takes about a second regardless of data size.

Snapshot mid-episode, then branch

denv snapshot <env>
denv fork --name rollout-017-b <env>

snapshot captures the live state as a new version: databases are checkpointed, writers are frozen for the capture, every volume is captured at the same instant, writers resume and health is re-checked. The environment then points at the new version, so the next fork starts from it.

From Python, Client.fork(env_id) snapshots first by default; pass live=False to fork the last version without a new snapshot.

Fork for one episode through the sandbox API

curl -s -X POST $DENV_SERVER/v1/sandboxes -H "Authorization: Bearer $DENV_API_KEY" \
  -H 'Content-Type: application/json' -d '{"from_version":"ver_01…","name":"ep-42"}'

Returns when healthy. Destroy it when the episode ends:

denv env destroy <env>

Roll back

denv env versions <env>
denv rollback <env> ver_01…

Rollback restores the version's snapshot and re-checks health. The spec is the version's, so it is a full return to that state.

What persists

Named volumes in the compose file are what a snapshot captures and a fork carries. For sandboxes created from an image, the paths listed in volumes (default /work) are volumes; anything written elsewhere lives in the container's writable layer and is not carried by a fork.