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 exportedSnapshot value, e.g. m.Snapshot.Create(ctx, ...).
Snapshot.Create()
DestDir, local
uses its default snapshot directory and cloud uses managed storage. DestDir
selects a local parent or cloud host-volume directory.
Parameters
ctxcontext.ContextCancellation and deadline.
Name, source sandbox, labels, and integrity options.
Returns
The created local or cloud snapshot.
Example
Example
Snapshot.Open()
Example
Example
Parameters
ctxcontext.ContextCancellation and deadline.
pathOrNamestringBackend-relative snapshot name, ID, or path.
Returns
The opened local or cloud snapshot.
Snapshot.Get()
Example
Example
Parameters
ctxcontext.ContextCancellation and deadline.
nameOrDigeststringPublic 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()
Example
Example
Returns
All indexed handles.
Snapshot.ListDir()
ErrUnsupportedOperation.
Parameters
ctxcontext.ContextCancellation and deadline.
dirstringDirectory holding snapshot artifact subdirectories.
Returns
One artifact per parsed subdirectory.
Snapshot.Remove()
Example
Example
force is true.
Parameters
ctxcontext.ContextCancellation and deadline.
pathOrNamestringBare name or artifact path.
forceboolDelete even if the snapshot has indexed children.
Snapshot.Reindex()
Example
Example
dir and rebuild the local index from the artifacts it finds. Cloud
returns ErrUnsupportedOperation.
Parameters
ctxcontext.ContextCancellation and deadline.
dirstringDirectory to scan for snapshot artifacts.
Returns
uint32
Number of artifacts indexed.
Snapshot.Save()
.tar.zst archive at outPath. Set
SnapshotSaveOptions.PlainTar to skip
compression. Cloud returns ErrUnsupportedOperation.
Parameters
ctxcontext.ContextCancellation and deadline.
nameOrPathstringBare name or artifact path to save.
outPathstringDestination archive path.
Whether to include parents, the base image, and compression.
Example
Example
Snapshot.Load()
dest directory. Pass "" for the default destination. Cloud returns
ErrUnsupportedOperation.
Parameters
ctxcontext.ContextCancellation and deadline.
archivestringPath to the snapshot archive.
deststringDestination directory, or
"" for the default snapshots directory.Returns
Handle to the loaded snapshot.
Example
Example
SandboxHandle methods
Snapshots are taken from a metadata handle, so stop the sandbox first and then callGetSandbox.
h.Snapshot()
Parameters
ctxcontext.ContextCancellation and deadline.
namestringBare name for the artifact.
Returns
The created artifact.
Example
Example
SnapshotArtifact methods
A local or cloud disk snapshot. The accessors below are plain field reads.s.SaveTo()
ErrUnsupportedOperation.
s.Verify()
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.
Example
Example
s.Reference()
SnapshotArtifact itself to
WithFromSnapshot so its typed reference is preserved as well.
s.ReferenceKind()
"id" or "path". Most callers can pass the artifact itself and
never inspect this value.
s.Digest()
sha256:...).
s.SizeBytes()
s.ImageRef()
s.ImageManifestDigest()
s.Format()
"raw" or "qcow2".
s.Scope()
SnapshotScopeDisk ("disk") or SnapshotScopeResumable ("resumable"). Always SnapshotScopeDisk today; SnapshotScopeResumable is reserved for resumable snapshots.
s.Fstype()
s.Parent()
nil if this snapshot has no parent. Returns a defensive copy.
s.CreatedAt()
s.Labels()
s.SourceSandbox()
nil. Returns a defensive copy.
SnapshotHandle methods
A lightweight handle returned by the active backend. The handle retains a stable reference used byOpen, Remove, and
SaveTo.
h.Open()
Example
Example
Returns
The opened artifact.
h.Remove()
Example
Example
Parameters
ctxcontext.ContextCancellation and deadline.
forceboolDelete even if the snapshot has indexed children.
h.SaveTo()
ErrUnsupportedOperation.
h.Digest()
h.Name()
nil. Returns a defensive copy.
h.ParentDigest()
nil. Returns a defensive copy.
h.ImageRef()
h.Format()
"raw" or "qcow2".
h.Scope()
SnapshotScopeDisk ("disk") or SnapshotScopeResumable ("resumable"). Always SnapshotScopeDisk today.
h.SizeBytes()
nil if unknown.
h.ReferenceKind()
"id" or "path" for the handle’s backend-neutral reference.
h.CreatedAt()
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()
ConfiguresSnapshot.Create. Name and FromSandbox are both required.
SnapshotSaveOptionsstruct
Accepted by Snapshot.Save() and instance SaveTo() methods
Snapshot.Save and instance SaveTo() methods.
SnapshotVerifyReportstruct
Returned by s.Verify()
Result ofVerify.
SnapshotUpperVerifyStatusstruct
Field of SnapshotVerifyReport
Upper-layer integrity details inside aSnapshotVerifyReport.
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.