Skip to content

Snapshots

View as Markdown

A snapshot is a capture of the memory and disk of a running sandbox, saved under a name. A sandbox restored from a snapshot resumes the captured processes and memory instead of booting. Deleting the source sandbox does not affect its snapshots.

A Linux sandbox produces a full snapshot, and only a sandbox served from a warm template can be captured. A snapshot restores only in its home region, on the runner that captured it. macOS sandboxes do not produce these snapshots: a macOS filesystem snapshot saves the disk of a stopped persistent sandbox as an image, and it restores on any Mac of the region.

A snapshot holds a running state. To save only the filesystem of a sandbox, capture an image instead. To register a registry image or a Dockerfile build under a name, pull or build an image.

ConceptDescription
Full snapshotKind full. The memory and disk of a running Linux sandbox that is served from a warm template.
RestoreA new sandbox that resumes the captured processes and memory, with the CPU, memory, and disk of the source.
Home regionThe region of the source sandbox. A snapshot restores only there, on the runner that captured it.
NameUnique in the project. Snapshots and images share one name space.

Snapshots are used when a new sandbox must continue from a running state instead of booting and repeating its setup.

  • Checkpoints of running work: a full snapshot saves the memory and disk of a running sandbox. A restore resumes the captured processes instead of starting them again.
  • Fast starts for slow-booting programs: a full snapshot taken after a server, a kernel, or a model has loaded restores with that program already running. New sandboxes skip the load time.
  • Evaluation and reinforcement learning (RL): each test case or episode resumes from the same snapshot. Results do not depend on another run.
  • Parallel attempts from one state: several sandboxes restore from the same snapshot, and each continues on its own. An agent tries several approaches from one point without repeating the setup.
  • Debugging and reproduction: a snapshot captures a sandbox in the state where a problem occurs. A restored sandbox reproduces that state, with its processes and memory, for inspection.
  • State that outlives the sandbox: deleting the source sandbox does not affect its snapshots. The sandbox is deleted to free its resources, and its state is restored later in its home region.

Create a snapshot of a running sandbox. The capture runs in the background: the snapshot starts as pending and becomes ready when the capture finishes.

from daytona import Daytona
daytona = Daytona()
# Snapshot capture needs a sandbox served from a warm template (see the notes)
sandbox = daytona.v2.create("my-image")
snapshot = sandbox.create_snapshot("my-snapshot")
print(snapshot.id, snapshot.kind, snapshot.status)
ParameterTypeDescription
namestrSets the snapshot name, 1 to 128 characters of letters, digits, ., _, and -. Snapshots and images in the project share one name space. A name in use fails with 409. This parameter is required.

The response has the following fields:

FieldDescription
statusThe status is pending, because the call returns once the capture is queued. To wait, call daytona.v2.snapshots.get(snapshot.id, wait="ready"). It returns at ready or failed, or after the server wait. The server wait is 30 seconds by default, and timeout sets it in seconds, up to 60.
  • The sandbox must be running.
  • On a Linux sandbox, this call captures kind full, which requires a sandbox served from a warm template.
KindCapturesRestore behavior
fullMemory and disk of a Linux sandboxResumes the captured processes and memory. Requires a sandbox served from a warm template. Pinned to the region and to the runner that captured it.
StatusMeaning
pendingAccepted; the capture job is queued on the sandbox’s runner.
capturingThe runner is pausing, copying, and packing the sandbox state.
readyRestorable.
failedTerminal. error carries the reason. The source sandbox keeps running.

Restore a sandbox from a snapshot. It resumes the captured processes and memory and keeps the source sandbox’s CPU, memory, and disk. A snapshot restores only in its home region, on the runner that captured it, and fails while that runner is unavailable.

from daytona import Daytona
daytona = Daytona()
sandbox = daytona.v2.create_from_snapshot("my-snapshot")
ParameterTypeDescription
snapshotstrSets the snapshot to restore from, by name or by ID, snap_.... This parameter is required.
namestrSets the display name. If omitted, a name is generated.
labelsDict[str, str]Attaches key-value metadata to the sandbox.
lifecycle_policyLifecyclePolicyConfigSets the lifecycle policy. It takes the same fields as lifecycle_policy in create a Linux sandbox.
portsSequence[PortMapping]Forwards inbound ports to the sandbox.
regionstrSets the region or global region slug. The default is the project default.
idempotency_keystrMakes a retried create return the same sandbox.
wait_secondsintSets the wait time in seconds. The default is 60.
create_timeout_secondsintSets how many seconds the sandbox has to reach running before it is deleted. The default is 3600, and the maximum is 86400.
from daytona import Daytona
daytona = Daytona()
page = daytona.v2.snapshots.list()
for snapshot in page.items:
print(snapshot.name, snapshot.kind, snapshot.status)
FieldDescription
idSnapshot ID.
nameUnique name within the project. Used for restore.
classlinux.
kindfull.
statuspending, capturing, ready, or failed.
sandbox_idThe source sandbox. null once the source sandbox is deleted.
regionHome region. The only region the snapshot can be restored in.
available_inRegions the snapshot can be restored in. Always [region].
bytesSize of the snapshot in bytes.
memory_bytesSize of the captured memory, full only.
errorFailure reason when status is failed.
from daytona import Daytona
daytona = Daytona()
for snapshot in daytona.v2.snapshots.iter():
print(snapshot.name, snapshot.kind, snapshot.status)
from daytona import Daytona
daytona = Daytona()
snapshot = daytona.v2.snapshots.get("{snapshotId}")
print(snapshot.kind, snapshot.status)
  • get takes the snapshot ID, snap_..., not the name.
  • To find a snapshot by name, call daytona.v2.snapshots.list(name="my-snapshot").

Delete a snapshot. It cannot be deleted while a sandbox restored from it exists.

  1. Go to Daytona Dashboard ↗
  2. Open the actions menu of a snapshot and click Delete
  3. Click Delete to confirm
from daytona import Daytona
daytona = Daytona()
daytona.v2.snapshots.delete("{snapshotId}")