Skip to main content
Disk-only snapshots of a sandbox that is not running. Local snapshots are portable artifacts; cloud snapshots use managed storage or the organization’s host volume. See Snapshots for concepts and walkthroughs.
Snapshots are disk-only and require a sandbox that is stopped or crashed. ListDir, Reindex, Save/SaveTo, Load, and Verify retain the same API on every backend, but currently return ErrUnsupportedOperation in cloud.

Snapshot functions

Package-level helpers for snapshot artifacts. Access them through the exported Snapshot value, e.g. m.Snapshot.Create(ctx, ...).

Snapshot.Create()

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

Parameters

ctxcontext.Context
Cancellation and deadline.
Name, source sandbox, labels, and integrity options.

Returns

The created local or cloud snapshot.

Snapshot.Open()

Open an existing snapshot using a backend-relative string. Bare values identify managed snapshots in cloud; path-like values identify host-volume artifacts.

Parameters

ctxcontext.Context
Cancellation and deadline.
pathOrNamestring
Backend-relative snapshot name, ID, or path.

Returns

The opened local or cloud snapshot.

Snapshot.Get()

Look up a lightweight handle through the active backend.

Parameters

ctxcontext.Context
Cancellation and deadline.
nameOrDigeststring
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. Cloud lists managed snapshots; host-volume artifacts are opened explicitly by reference.

Returns

All indexed handles.

Snapshot.ListDir()

Walk a local directory and parse each subdirectory’s manifest without touching the local index. Cloud returns ErrUnsupportedOperation.

Parameters

ctxcontext.Context
Cancellation and deadline.
dirstring
Directory holding snapshot artifact subdirectories.

Returns

One artifact per parsed subdirectory.

Snapshot.Remove()

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

Parameters

ctxcontext.Context
Cancellation and deadline.
pathOrNamestring
Bare name or artifact path.
forcebool
Delete even if the snapshot has indexed children.

Snapshot.Reindex()

Walk dir and rebuild the local index from the artifacts it finds. Cloud returns ErrUnsupportedOperation.

Parameters

ctxcontext.Context
Cancellation and deadline.
dirstring
Directory to scan for snapshot artifacts.

Returns

uint32
Number of artifacts indexed.

Snapshot.Save()

function
Bundle a local snapshot into a .tar.zst archive at outPath. Set SnapshotSaveOptions.PlainTar to skip compression. Cloud returns ErrUnsupportedOperation.

Parameters

ctxcontext.Context
Cancellation and deadline.
nameOrPathstring
Bare name or artifact path to save.
outPathstring
Destination archive path.
Whether to include parents, the base image, and compression.

Snapshot.Load()

function
Unpack a snapshot archive into the local snapshots directory or an explicit dest directory. Pass "" for the default destination. Cloud returns ErrUnsupportedOperation.

Parameters

ctxcontext.Context
Cancellation and deadline.
archivestring
Path to the snapshot archive.
deststring
Destination directory, or "" for the default snapshots directory.

Returns

Handle to the loaded snapshot.

SandboxHandle methods

Snapshots are taken from a metadata handle, so stop the sandbox first and then call GetSandbox.

h.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

ctxcontext.Context
Cancellation and deadline.
namestring
Bare name for the artifact.

Returns

The created artifact.

SnapshotArtifact methods

A local or cloud disk snapshot. The accessors below are plain field reads.

s.SaveTo()

Bundle this snapshot through the active backend while preserving its typed identifier-or-path reference. Cloud returns ErrUnsupportedOperation.

s.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. The report’s Upper.Kind is "not_recorded" when the artifact was created without RecordIntegrity, and "verified" when the recorded value matched.

Returns

Recomputed digest and upper-layer status.

s.Reference()

Stable backend-relative value. Prefer passing the SnapshotArtifact itself to WithFromSnapshot so its typed reference is preserved as well.

s.ReferenceKind()

Returns "id" or "path". Most callers can pass the artifact itself and never inspect this value.

s.Digest()

Canonical manifest digest (sha256:...).

s.SizeBytes()

Backend-reported stored payload size in bytes.

s.ImageRef()

Image reference the snapshot was taken from.

s.ImageManifestDigest()

Pinned OCI manifest digest of the base image.

s.Format()

Upper-layer disk format: "raw" or "qcow2".

s.Scope()

method
Snapshot scope: SnapshotScopeDisk ("disk") or SnapshotScopeResumable ("resumable"). Always SnapshotScopeDisk today; SnapshotScopeResumable is reserved for resumable snapshots.

s.Fstype()

Filesystem type inside the upper layer.

s.Parent()

Parent digest, or nil if this snapshot has no parent. Returns a defensive copy.

s.CreatedAt()

RFC 3339 creation timestamp.

s.Labels()

User labels recorded at creation. Returns a defensive copy.

s.SourceSandbox()

Best-effort source sandbox name, or nil. Returns a defensive copy.

SnapshotHandle methods

A lightweight handle returned by the active backend. The handle retains a stable reference used by Open, Remove, and SaveTo.

h.Open()

Open the underlying snapshot metadata using this handle’s stable reference.

Returns

The opened artifact.

h.Remove()

Remove this snapshot using this handle’s stable reference.

Parameters

ctxcontext.Context
Cancellation and deadline.
forcebool
Delete even if the snapshot has indexed children.

h.SaveTo()

Bundle the referenced snapshot through the active backend while preserving the handle’s typed identifier-or-path reference. Cloud returns ErrUnsupportedOperation.

h.Digest()

Manifest digest.

h.Name()

Bare-name alias, if the snapshot was indexed with one; otherwise nil. Returns a defensive copy.

h.ParentDigest()

Parent digest, or nil. Returns a defensive copy.

h.ImageRef()

Pinned image reference.

h.Format()

Upper-layer disk format: "raw" or "qcow2".

h.Scope()

method
Snapshot scope: SnapshotScopeDisk ("disk") or SnapshotScopeResumable ("resumable"). Always SnapshotScopeDisk today.

h.SizeBytes()

Backend-reported stored payload size, or nil if unknown.

h.ReferenceKind()

Returns "id" or "path" for the handle’s backend-neutral reference.

h.CreatedAt()

Snapshot creation time, decoded from the index’s Unix timestamp.

Types

SnapshotArtifactstruct

Returned by Snapshot.Create() · Snapshot.Open() · Snapshot.ListDir() · h.Snapshot() · h.Open()

A backend-neutral disk snapshot. Fields are unexported; read them through the accessor methods below.

SnapshotHandlestruct

Returned by Snapshot.Get() · Snapshot.List() · Snapshot.Load()

A lightweight handle returned by the active backend. Fields are unexported; read them through the accessor methods below.

SnapshotCreateOptionsstruct

Accepted by Snapshot.Create()

Configures Snapshot.Create. Name and FromSandbox are both required.

SnapshotSaveOptionsstruct

Accepted by Snapshot.Save() and instance SaveTo() methods

Configures Snapshot.Save and instance SaveTo() methods.

SnapshotVerifyReportstruct

Returned by s.Verify()

Result of Verify.

SnapshotUpperVerifyStatusstruct

Field of SnapshotVerifyReport

Upper-layer integrity details inside a SnapshotVerifyReport.

Snapshot scope constants

Returned by s.Scope() · h.Scope()

Scope of what a snapshot captures. Every snapshot today is disk-only; the resumable scope (disk plus VM state) is reserved for resumable snapshots.