Skip to main content
See the snapshot guide for workflows and examples. Use snapshot objects or references on cloud. Local operations also accept a group head, group:member, or artifact path.

Guest writeback

Pass guest_flush=GuestFlush.REQUIRED to Snapshot.create, Snapshot.create_archive, source.fork, source.fork_many, or source.pause. Import GuestFlush from microsandbox. The default AUTO flushes live disk-only captures, but adds no optional flush to full captures, forks, or pause. SKIP retains mandatory storage barriers. A paused disk capture needs a matching prior flush; cloud rejects non-Auto policies. See guest flush policy reference.

Snapshot

class

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

Create, open, and manage snapshots. See properties for returned metadata.

Snapshot.create()

Create a disk snapshot, or set full=True to include memory and execution state. name identifies a member within group; an omitted name is generated and an omitted group uses the source sandbox’s name. dest_dir selects the parent directory containing the group. from_sandbox names the sandbox to capture and is required.

Parameters

namestr
Snapshot member name; generated when omitted.
from_sandboxstr
Name of the source sandbox. Local disk capture supports running, paused, stopped, and crashed sources. Cloud requires a stopped persistent source. Required.
dest_dirstr | os.PathLike[str] | None
Parent directory containing snapshot groups. Defaults to the snapshots directory.
labelsdict[str, str] | None
User-supplied local labels stored outside the identity-bearing descriptor.
forcebool
Must remain False for installed group members. Since v0.7, True raises InvalidConfigError even when the name does not exist. Use a new or generated member name, or explicitly remove the existing member before recreating it. See the v0.6 upgrade example. Direct archive capture supports overwriting its output file.
record_integritybool
Record an integrity hash in the manifest so the artifact can be verified later. Default False.
fullbool
Local-only when True: capture disk, memory, execution, and device state from a running or paused sandbox. Default False captures disk state; locally, the source can be running, paused, stopped, or crashed. Cloud requires False and a stopped persistent source.
guest_flushGuestFlush | None
Guest writeback policy. Omitted selects AUTO; see guest writeback.

Returns

The captured snapshot.

Snapshot.create_archive()

Capture directly into an archive without installing a local snapshot.

Snapshot.open()

Open an existing artifact by group head, group:member, or path. This validates metadata without reading the full upper file. Use verify() for content checks.

Parameters

path_or_namestr
Group head, group:member, or artifact directory path.

Returns

The opened snapshot.

Snapshot.get()

Look up a handle by group head, group:member, stable snapshot ID, descriptor digest, or artifact path. Global IDs and digests must resolve unambiguously.

Parameters

name_or_digeststr
Group head, group:member, stable snapshot ID, descriptor digest, or artifact path.

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
Group head, group:member, 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 snapshot into a .msb archive. The existing snapshot manifest is archived as-is; create the snapshot with recorded integrity when the archive will cross a trust boundary.

Parameters

name_or_pathstr
Group head or group:member 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 .msb. Default False.


Snapshot.load()

staticasync
Unpack a snapshot archive (.msb or .tar) into the selected or generated group. The returned handle’s group identifies the group and head_update reports the head selection outcome. Structural and archive-entry checks run during import; recorded payload integrity is preserved for explicit verify(). Compression is detected from magic bytes.

Parameters

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

Returns

Handle to the loaded snapshot.

Snapshot.load_many()

Import archives as one batch. Returns handles in input order. Dependencies resolve from the batch, the named group, or an explicit base; input order does not matter. All members are validated before publication.

Snapshot.group_head()

Read a group’s head, or select an exact member with group:member. Returns the group, previous and current snapshot IDs, reason, and whether the head changed. See group selection.

Import options

Options for load() and load_many(). With divergent tips, the existing head stays selected; a new group has no head. Select a member explicitly. Identical members may be reused; conflicting identities fail. See archive imports.

Snapshot methods

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()

Verify the snapshot’s complete state closure. File state recomputes recorded upper-layer integrity. Checkpoint state validates the complete checkpoint closure and returns checkpoint={"kind": "verified", "root": ...} in the report.

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:

SnapshotHandle methods

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 installed snapshot copy and its index row using the handle’s stored artifact path. Other groups containing the same snapshot ID or digest remain unchanged. 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.

SandboxHandle

handle.snapshot()

Snapshot this sandbox into its default group with the given member name. Local live disk captures preserve the source’s running or paused state. Cloud requires a stopped persistent source. Use the returned artifact path or sandbox:member to open it later. Called on a SandboxHandle, obtained from Sandbox.get().

Parameters

namestr
Member name within the source sandbox’s group.

Returns

The captured snapshot.

Restore

Restore into a new detached sandbox. Disk boots fresh; full resumes execution. See restore examples and progress.
Image, replacement, and startup-command options are not accepted. Full restore requires matching CPU and memory settings, keeps captured network devices, and cannot apply a new guest security profile. Use disk-only restore to change these. Full restore rejects missing external filesystems and additional disks by default. Use allow_missing_resources=True to resume with unavailable devices and warnings. This is separate from strict/relaxed validation of supplied mappings; inheritance does not waive missing backing. Root and owned storage remain required.
Omitted controls retain destination defaults. Durations are non-negative finite seconds, rounded up. Network policy accepts NetworkPolicy, not Network. captured_volumes contains guest paths.

Compaction

Compact a local sandbox’s root or owned disks. See compaction for examples and recovery requirements.
Defaults to the root and owned data disks; excludes named/external volumes and directories. Requires a running or fully stopped local sandbox. Fewer than two sealed layers means no change; no eligible disks returns an empty result with zero counts.Results include aggregate counts and per-disk entries keyed by guest_path. materialized_bytes counts copied bytes, not reclaimed space. Times are microseconds: per-disk total_us covers preparation; aggregate total_us also includes switching; pause_us measures the shared VM pause.

Types

Snapshot properties

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.