Sign Up

Snapshots

Captures of the memory and disk of a running sandbox that new sandboxes resume from.

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 persistent sandbox or one served from a warm template can be captured. A GPU sandbox produces a checkpoint that also holds GPU memory. A full snapshot restores in its home region, on the runner that captured it or on another runner of the region with the same CPU model and hypervisor version. Where Daytona has enabled cross-region restore, a full snapshot of a sandbox that is not persistent can also restore in another region, which receives a copy of it first. Without it, a restore that names another region returns 400. A checkpoint restores on any GPU runner in the region that meets the restore requirements. Windows sandboxes do not support snapshots. 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 snapshotThe memory and disk of a running persistent Linux sandbox or one served from a warm template.
CheckpointThe processes, memory, and GPU memory of a running GPU sandbox.
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 there unless the restore names another region.
NameUnique in the project. Snapshots and images share one name space.

Use cases

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. The capture runs in the background, and the source sandbox keeps running if the capture fails.

  • 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. The program must run in a persistent Linux sandbox or one served from a warm template, because only those sandboxes can be captured.

  • Evaluation and reinforcement learning (RL). Each test case or episode resumes from the same snapshot. Results do not depend on another run. Every restored sandbox keeps the CPU, memory, and disk of the source, so each run gets the same resources.

  • Long GPU jobs. A checkpoint saves a GPU job together with its GPU memory. A new GPU sandbox resumes the job from the point it was saved. The checkpoint restores on any GPU runner in the region that meets the restore requirements.

  • 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. The snapshot cannot be deleted while a sandbox restored from it exists.

Create snapshots

Create a snapshot of a running sandbox. The capture runs in the background: the snapshot starts as pending, is building while the runner captures the sandbox, and becomes ready when the capture finishes. Deleting the source sandbox during the capture fails the snapshot.

from daytona import Daytona

daytona = Daytona()
# Snapshot capture needs a persistent sandbox or one served from a warm template
sandbox = daytona.v2.create()

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 -. It cannot start with . or with the reserved prefixes sbx_, vol_, fn_, snap-, build-, refs, by-digest, prj-, and glb-. Names are case-sensitive. This parameter is required. Snapshots and images in the project share one name space. A name in use fails with 409.

The response has the following fields:

FieldDescription
statusThe status is pending or building, because the call returns before the capture finishes. To wait, call daytona.v2.snapshots.get(snapshot.id, wait="ready"). It returns at ready or failed, or after the server wait of 30 seconds. timeout sets a total wait in seconds: the SDK repeats the server wait until the snapshot is ready or failed, and raises RequestTimeoutError if the time runs out first.
KindCapturesRestore behavior
fullMemory and disk of a Linux sandboxResumes the captured processes and memory. Requires a persistent sandbox or one served from a warm template. Restores in its home region. A snapshot of a sandbox that is not persistent also restores in a region whose runners have the same CPU model and hypervisor version.
checkpointProcesses, memory, and GPU memory of a GPU sandboxResumes in a new GPU sandbox. See GPU sandboxes.
StatusMeaning
pendingAccepted; the capture job is queued on the sandbox's runner.
buildingThe runner is pausing, copying, and packing the sandbox state.
readyRestorable.
failedTerminal. error carries the reason. The source sandbox keeps running.

Restore snapshots

Restore a sandbox from a snapshot. It resumes the captured processes and memory and keeps the source sandbox's CPU, memory, disk, and persistence. The restore runs on the runner that captured the snapshot when that runner can take it, and otherwise on another runner of the region with the same CPU model and hypervisor version. Where cross-region restore is enabled, a restore in another region waits while the snapshot is copied there.

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_policyLifecyclePolicyOptionsSets the lifecycle policy. It takes the same fields as lifecycle_policy in create a Linux sandbox.
portsSequence[PortMapping]Forwards inbound ports to the sandbox. Import PortMapping from daytona.v2, for example PortMapping(port=8080).
regionstrSets the region. The default is the snapshot's home region. Another region requires cross-region restore to be enabled, a source sandbox that was not persistent, and runners in that region with the CPU model and hypervisor version of the snapshot.
idempotency_keystrMakes a retried create return the same sandbox. If name is set, the key is derived from it. Otherwise, each call generates a new key.
wait_secondsintSets how many seconds create waits for the sandbox to start. The server holds the request for up to 3 seconds, and the SDK waits for the rest. 0 returns immediately. The default is 60.
create_timeout_secondsintSets how many seconds the sandbox has to reach running before it is deleted, at most 86400. -1 sets the maximum. The default is 3600.

Operations

List snapshots

from daytona import Daytona

daytona = Daytona()

page = daytona.v2.snapshots.list()
for snapshot in page.items:
    print(snapshot.name, snapshot.kind, snapshot.status)
ParameterTypeDescription
namestrFilters the list by exact snapshot name.
sandbox_idstrFilters the list to snapshots captured from this sandbox.
limitintSets the page size, from 1 to 200. The default is 100.
cursorstrResumes the list after the previous page. Pass the next_cursor of that page.

The API returns the following fields. The SDKs use the same names, except where the description says otherwise.

FieldDescription
idSnapshot ID.
nameUnique name within the project. Used for restore.
classlinux or gpu. The SDKs name it sandbox_class in Python and sandboxClass in TypeScript.
kindfull for Linux, or checkpoint for GPU.
statuspending, building, ready, or failed.
sandbox_idThe ID of the source sandbox. It stays after the source sandbox is deleted, and becomes null once Daytona purges the record of the deleted sandbox.
region_idHome region. The SDKs name it region.
region_idsThe home region, followed by every other region that holds a copy of the snapshot. The SDKs name it available_in in Python and availableIn in TypeScript.
bytesSize of the captured disk in bytes. null for full snapshots.
memory_bytesSize of the captured memory, full only.
errorFailure reason when status is failed.

Iterate over all snapshots

from daytona import Daytona

daytona = Daytona()

for snapshot in daytona.v2.snapshots.iter():
    print(snapshot.name, snapshot.kind, snapshot.status)

Get a snapshot

from daytona import Daytona

daytona = Daytona()

snapshot = daytona.v2.snapshots.get("{snapshotId}")
print(snapshot.kind, snapshot.status)

Delete snapshots

Delete a snapshot. It cannot be deleted while a sandbox restored from it exists, including a restored sandbox whose deletion has not finished.

  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}")

Errors

The SDKs raise these errors with the codes in the following table, and the API returns them in the code field.

CodeMeaningWhat to do
SNAPSHOT_NOT_FOUNDThe restore names a snapshot that does not exist in the project.Check the name or ID with list snapshots.
SNAPSHOT_NOT_READYThe restore names a snapshot that is pending, building, or failed.Wait until the snapshot is ready. A failed snapshot does not become ready: create a new one.
NOT_SUPPORTED_FOR_CLASSThe snapshot create names a Windows or macOS sandbox.To save the disk, capture an image.
IDEMPOTENCY_KEY_REQUIREDAn API restore names a region that covers other regions, such as us-east, without an Idempotency-Key header. The SDKs and the CLI always send a key.Pass an idempotency key, or name a single region.
CONFLICTThe name is in use by a snapshot or an image, the sandbox is not running, the Linux sandbox is neither persistent nor served from a warm template, the target region has no runner with the CPU model and hypervisor version of the snapshot, or a delete names a snapshot that a sandbox still references.Use another name, start the sandbox, restore in the home region, or delete the restored sandboxes first.
BAD_REQUESTThe snapshot name is invalid, the restore names another region that the snapshot cannot be copied to (for example, cross-region restore is not enabled, the source sandbox was persistent, or the snapshot is too large), the restore names a checkpoint, or the path value matches both a snapshot ID and the name of another snapshot.Fix the name, restore in the home region, restore a checkpoint as a GPU sandbox, or pass id_only.

Permissions

Snapshots are scoped to a project. Access is governed by three permissions, which you can grant to an organization role or an API key.

Restoring a snapshot creates a sandbox, so it requires the permission to create sandboxes. The audit logs record snapshot creates and deletes.

PermissionGrants
read:snapshotsList and get snapshots
write:snapshotsCreate snapshots
delete:snapshotsDelete snapshots