Skip to main content
Capture the disk state of a stopped sandbox through the active backend, then boot fresh sandboxes from it. Local snapshots are reusable artifacts; cloud snapshots use managed storage or the organization’s host volume. Snapshots are disk-only and require a sandbox that is not running.
list_dir, reindex, save/save_to, copy_to, load, and verify keep the same API on every backend, but currently raise UnsupportedError in cloud.

Take a snapshot

handle.snapshot()

Snapshot this sandbox under a bare name. Local uses its default snapshot directory; cloud uses managed storage. The sandbox must be stopped or crashed.

Parameters

namestr
Snapshot name. Local stores it in the default snapshot directory; cloud creates a managed snapshot.

Returns

The captured snapshot.

Snapshot.create()

Create a snapshot from a stopped or crashed sandbox. With no dest_dir, local uses its default snapshot directory and cloud uses managed storage. A dest_dir selects a local parent or cloud host-volume directory.

Parameters

namestr
Snapshot name. Its storage location is selected by the active backend.
from_sandboxstr
Name of the stopped or crashed sandbox to capture. Required.
dest_dirstr | os.PathLike[str] | None
Local parent or cloud host-volume directory. Omit for backend-managed storage.
labelsdict[str, str] | None
User-supplied labels stored in the manifest.
forcebool
Overwrite an existing artifact with the same name. Default False.
record_integritybool
Record an integrity hash in the manifest so the artifact can be verified later. Default False.
resumablebool
Request a “resumable” snapshot (disk plus VM state). Accepted, but currently fails with an Unsupported error; resumable snapshots have not landed yet. Default False.

Returns

The captured snapshot.

Boot from a snapshot

Sandbox.create()

Boot a fresh sandbox from a snapshot by passing from_snapshot= as a peer of image=. The two are mutually exclusive. Passing a Snapshot or SnapshotHandle preserves its backend-relative reference automatically.

Parameters

namestr
Sandbox name, up to 128 UTF-8 bytes.
from_snapshotstr | os.PathLike | Snapshot | SnapshotHandle | None
Backend-relative string, path, or snapshot object to boot from instead of image=.

Returns

Running sandbox.

Manage artifacts

Snapshot.open()

Open an existing snapshot through the active backend. Locally, bare names resolve under the default snapshot directory and other values are artifact paths. In cloud, bare values identify managed snapshots and path-like values identify host-volume artifacts. Cheap metadata validation only; use verify() for content checks where supported.

Parameters

path_or_namestr
Backend-relative snapshot name, ID, or path.

Returns

The opened snapshot.

Snapshot.get()

Look up a lightweight snapshot handle through the active backend.

Parameters

name_or_digeststr
Public identifier understood by the active backend, such as a local name/digest or cloud snapshot ID.

Returns

Lightweight handle returned by the active backend.

Snapshot.list()

List snapshots visible through the active backend. Local uses its index; cloud lists managed snapshots. Host-volume artifacts are opened explicitly by reference.

Returns

Indexed snapshot handles.

Snapshot.list_dir()

Walk a local directory and parse each subdirectory’s manifest. Does not touch the local index, useful for inspecting external snapshot collections. Skips entries that don’t look like snapshot artifacts. Cloud raises UnsupportedError.

Parameters

dirstr | os.PathLike
Directory to scan for artifacts.

Returns

One snapshot per valid artifact directory.

Snapshot.remove()

Remove a snapshot through the active backend. Locally, removal also updates the index and refuses indexed children unless force=True.

Parameters

path_or_namestr
Bare snapshot name or artifact path.
forcebool
Remove even if the snapshot has indexed children. Default False.

Snapshot.reindex()

Walk dir (default: configured snapshots dir) and rebuild the local index. Returns the number of artifacts indexed. Cloud raises UnsupportedError.

Parameters

dirstr | os.PathLike | None
Directory to scan. Default: the configured snapshots directory.

Returns

int
Number of artifacts indexed.

Snapshot.save()

staticasync
Bundle a local snapshot into a .tar.zst archive. The existing snapshot manifest is archived as-is; create the snapshot with recorded integrity when the archive will cross a trust boundary. Cloud raises UnsupportedError.

Parameters

name_or_pathstr
Snapshot bare name or artifact path to save.
outstr | os.PathLike
Output archive path.
with_parentsbool
Include the snapshot’s parent chain. Default False.
with_imagebool
Include the pinned base image. Default False.
plain_tarbool
Write an uncompressed .tar instead of .tar.zst. Default False.

Move artifacts


Snapshot.load()

staticasync
Unpack a snapshot archive (.tar.zst or .tar) into the local snapshots directory. Structural and archive-entry checks run during import; recorded payload integrity is preserved for explicit verify(). Compression is detected from magic bytes. Cloud raises UnsupportedError.

Parameters

archivestr | os.PathLike
Archive path (.tar.zst or .tar).
deststr | os.PathLike | None
Destination directory. Default: the configured snapshots directory.

Returns

Handle to the loaded snapshot.

Inspect

snap.save_to()

Bundle this snapshot through the backend retained when it was created or opened. This avoids resolving its reference through a possibly different current default backend. Cloud raises UnsupportedError.

snap.copy_to()

Create a new archive from this snapshot’s disk data while replacing its labels and integrity metadata. The source snapshot is unchanged. Cloud raises UnsupportedError when save() is awaited.

snap.verify()

Recompute the upper layer’s recorded content integrity and compare against the descriptor. Current BLAKE3 Merkle integrity skips known all-hole subtrees and hashes allocated leaves in batches; released SHA descriptors retain their exact, potentially O(logical size), verifier. Returns not_recorded without reading payload contents when no integrity was stored. The cloud backend currently raises UnsupportedError.

Returns

dict[str, Any]
Verification report. The upper.kind field is “not_recorded” when no integrity hash was stored, or “verified” with the recomputed digest.
The report shape:

handle.open()

Load the full Snapshot metadata for this handle. Metadata-validated only; does not read the upper file.

Returns

The opened snapshot.

handle.remove()

Remove this snapshot artifact and its index row. Refuses if the snapshot has indexed children unless force=True.

Parameters

forcebool
Remove even if the snapshot has indexed children. Default False.

handle.save_to()

Bundle the referenced snapshot through the backend retained by the handle. Cloud raises UnsupportedError.

Types

Snapshot

class

Returned by snapshot() · Snapshot.create() · Snapshot.open() · Snapshot.list_dir() · handle.open()

A fully parsed backend-neutral snapshot. Properties are read-only attributes.

SnapshotCopyBuilder

Returned by Snapshot.copy_to(). Setters mutate the builder and return it so calls can be chained.

SnapshotHandle

class

Returned by Snapshot.get() · Snapshot.list() · Snapshot.load()

Lightweight handle returned by the active backend. Properties are read-only.

SnapshotStateKind

Returned by Snapshot.state_kind · SnapshotHandle.state_kind

Snapshot state representation.

SnapshotFormat

Returned by Snapshot.format · SnapshotHandle.format

On-disk format for file-backed snapshot state.

SnapshotScope

Returned by Snapshot.scope · SnapshotHandle.scope

Captured snapshot state scope.