Typical flow
Take a snapshot
handle.snapshot()
~/.microsandbox/snapshots/<name>/). The sandbox must be stopped or crashed. To place the artifact elsewhere, use Snapshot.save() / Snapshot.load() or move the self-contained artifact directory. Called on a SandboxHandle, obtained from Sandbox.get().
Parameters
namestrSnapshot name; resolved under the default snapshots directory.
Returns
The captured snapshot.
Example
Example
Snapshot.create()
name is resolved under the default snapshots directory (~/.microsandbox/snapshots/<name>/), or under dest_dir= when given; from_sandbox= names the sandbox to capture and is required.
Parameters
namestrBare snapshot name; resolved under the default snapshots directory.
from_sandboxstrName of the stopped or crashed sandbox to capture. Required.
dest_dirstr | os.PathLike[str] | NoneParent directory to create the artifact in; the artifact lands at
dest_dir/<name>. Defaults to the snapshots directory.labelsdict[str, str] | NoneUser-supplied labels stored in the manifest.
forceboolOverwrite an existing artifact with the same name. Default
False.record_integrityboolRecord an integrity hash in the manifest so the artifact can be verified later. Default
False.resumableboolRequest 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.
Example
Example
Boot from a snapshot
Sandbox.create()
from_snapshot= as a peer of image=. The two are mutually exclusive: pass exactly one. See Sandbox.create() for the full set of configuration kwargs.
Parameters
namestrSandbox name, up to 128 UTF-8 bytes.
from_snapshotstr | os.PathLike | NoneSnapshot bare name or artifact path to boot from instead of
image=.Returns
Running sandbox.
Example
Example
Manage artifacts
Snapshot.open()
Example
Example
verify() for content checks.
Parameters
path_or_namestrBare snapshot name or artifact directory path.
Returns
The opened snapshot.
Snapshot.get()
Example
Example
Parameters
name_or_digeststrSnapshot name, digest, or path.
Returns
Lightweight handle backed by an index row.
Snapshot.list()
Example
Example
Returns
Indexed snapshot handles.
Snapshot.list_dir()
Parameters
dirstr | os.PathLikeDirectory to scan for artifacts.
Returns
One snapshot per valid artifact directory.
Snapshot.remove()
Example
Example
force=True.
Parameters
path_or_namestrBare snapshot name or artifact path.
forceboolRemove even if the snapshot has indexed children. Default
False.Snapshot.reindex()
Example
Example
dir (default: configured snapshots dir) and rebuild the local index. Returns the number of artifacts indexed.
Parameters
dirstr | os.PathLike | NoneDirectory to scan. Default: the configured snapshots directory.
Returns
int
Number of artifacts indexed.
Example
Example
Snapshot.save()
Example
Example
.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.
Parameters
name_or_pathstrSnapshot bare name or artifact path to save.
outstr | os.PathLikeOutput archive path.
with_parentsboolInclude the snapshot’s parent chain. Default
False.with_imageboolInclude the pinned base image. Default
False.plain_tarboolWrite an uncompressed
.tar instead of .tar.zst. Default False.Example
Example
Move artifacts
Snapshot.load()
.tar.zst or .tar) into the snapshots directory, verifying recorded integrity when present. Compression is detected from magic bytes.
Parameters
archivestr | os.PathLikeArchive path (
.tar.zst or .tar).deststr | os.PathLike | NoneDestination directory. Default: the configured snapshots directory.
Returns
Handle to the loaded snapshot.
Example
Example
Inspect
snap.verify()
Example
Example
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.handle.open()
Example
Example
Snapshot metadata for this handle. Metadata-validated only; does not read the upper file.
Returns
The opened snapshot.
handle.remove()
Example
Example
force=True.
Parameters
forceboolRemove even if the snapshot has indexed children. Default
False.Types
Snapshot
Returned by snapshot() · Snapshot.create() · Snapshot.open() · Snapshot.list_dir() · handle.open()
A fully-parsed snapshot artifact. Properties are read-only attributes (not async).SnapshotHandle
Returned by Snapshot.get() · Snapshot.list() · Snapshot.load()
Lightweight handle backed by an index row. Properties are read-only attributes (not async).