Skip to main content
Create and manage disk-only snapshots of stopped sandboxes. See Snapshots for usage and lifecycle concepts.

Snapshot

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. SnapshotCreateOptions.Name (resolved under the default snapshots directory) and SnapshotCreateOptions.FromSandbox (the sandbox to capture) are both required.

Parameters

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

Returns

The created artifact on disk.

Snapshot.Open()

Open an existing artifact by bare name or filesystem path. This validates metadata only; call s.Verify() for content checks.

Parameters

ctxcontext.Context
Cancellation and deadline.
pathOrNamestring
Bare name (resolved under the default snapshots directory) or artifact directory path.

Returns

The artifact on disk.

Snapshot.Get()

Look up a lightweight handle in the local index by name, digest, or path.

Parameters

ctxcontext.Context
Cancellation and deadline.
nameOrDigeststring
Bare name, manifest digest, or artifact path.

Returns

Index-backed handle.

Snapshot.List()

List indexed snapshots from the local DB cache.

Returns

All indexed handles.

Snapshot.ListDir()

Walk a directory and parse each subdirectory’s manifest without touching the index.

Parameters

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

Returns

One artifact per parsed subdirectory.

Snapshot.Remove()

Remove a snapshot artifact and its index row. Refuses to delete a snapshot with 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.

Parameters

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

Returns

uint32
Number of artifacts indexed.

Snapshot.Save()

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

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 snapshots directory or an explicit dest directory. Pass "" for the default destination.

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

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 in the default snapshots directory. The sandbox must be stopped or crashed. To place the artifact elsewhere, use Snapshot.Save / Snapshot.Load or move the self-contained artifact directory.

Parameters

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

Returns

The created artifact.

SnapshotArtifact

struct

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

A snapshot artifact on disk.

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

Artifact directory on disk.

s.Digest()

Canonical manifest digest (sha256:...).

s.SizeBytes()

Apparent upper-layer 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

struct

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

A snapshot handle backed by the local index.

h.Open()

Open the underlying artifact metadata. Equivalent to Snapshot.Open on this handle’s path.

Returns

The opened artifact.

h.Remove()

Remove this snapshot. Equivalent to Snapshot.Remove on this handle’s digest.

Parameters

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

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

Apparent upper size at index time, or nil if unknown. Returns a defensive copy.

h.Path()

Artifact directory on disk.

h.CreatedAt()

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

Constants

Snapshot scopes

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.

Types

SnapshotCreateOptionsstruct

Accepted by Snapshot.Create()

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

SnapshotSaveOptionsstruct

Accepted by Snapshot.Save()

Configures Snapshot.Save.

SnapshotVerifyReportstruct

Returned by s.Verify()

Result of Verify.

SnapshotUpperVerifyStatusstruct

Field of SnapshotVerifyReport

Upper-layer integrity details inside a SnapshotVerifyReport.