Snapshots are disk-only and require a sandbox that is not running (stopped or crashed).
Typical flow
Capture and boot
These entry points live onSandboxBuilder and SandboxHandle; they are the bridge between sandboxes and snapshot artifacts.
.fromSnapshot()
Example
Example
.image(); the snapshot already pins the image. Documented in full on the Sandbox page.
Parameters
pathOrNamestringBare name (resolved under the default snapshots directory) or filesystem path to an artifact directory.
Returns
The same builder, for chaining.
handle.snapshot()
~/.microsandbox/snapshots/<name>/). Called on a SandboxHandle. The sandbox must be stopped or crashed; running sandboxes are rejected with a SnapshotSandboxRunning error. To place the artifact elsewhere, use Snapshot.save() / Snapshot.load() or move the self-contained artifact directory.
Parameters
namestringBare name; becomes the artifact directory under the default snapshots dir.
Returns
The created snapshot artifact.
Example
Example
Snapshot static methods
Snapshot.builder()
name, resolved under the default snapshots directory (~/.microsandbox/snapshots/<name>/) or under .destDir() when set. The fluent builder is what powers the CLI internally. The source sandbox is set with .fromSandbox(), which is required. See SnapshotBuilder for all setters.
Parameters
namestringBare snapshot name; becomes the artifact directory under the default snapshots dir.
Returns
Builder for configuring the snapshot.
Example
Example
Snapshot.open()
Example
Example
verify() for content checks.
Parameters
pathOrNamestringBare name (resolved under the default snapshots dir) or filesystem path.
Returns
The opened snapshot.
Snapshot.get()
Example
Example
SnapshotHandle backed by the local index row.
Parameters
nameOrDigeststringName, digest (
sha256:…), or path of an indexed snapshot.Returns
Index-backed handle.
Snapshot.list()
Example
Example
Returns
All indexed snapshot handles.
Snapshot.listDir()
Parameters
dirstringDirectory to scan for artifact subdirectories.
Returns
Parsed snapshots found in the directory.
Snapshot.remove()
Example
Example
force is set.
Parameters
pathOrNamestringPath, name, or digest of the snapshot to remove.
opts.forcebooleanRemove even if the snapshot has indexed children. Defaults to
false.Snapshot.reindex()
Example
Example
Parameters
dirstringDirectory to scan. Defaults to the configured snapshots dir.
Returns
Promise<number>
Count of artifacts indexed.
Snapshot.save()
.tar.zst archive. The recorded manifest is archived as-is, so create the snapshot with recordIntegrity() if receivers must verify content. See SaveOpts for bundling options.
Parameters
nameOrPathstringName or path of the snapshot to bundle.
outstringOutput archive path.
optsSaveOptsBundling options. All fields default to
false.Example
Example
Snapshot.load()
.tar.zst or .tar) into the snapshots directory, verifying recorded integrity on the way in. Compression is detected from magic bytes.
Parameters
archivestringPath to the archive to unpack.
deststringDestination directory. Defaults to the snapshots directory.
Returns
Handle to the loaded snapshot.
Example
Example
Snapshot instance members
ASnapshot is a snapshot artifact on disk. The artifact is a directory containing the snapshot.json descriptor and the captured upper.ext4. The directory is the source of truth; the local DB index is just a rebuildable cache. Returned by Snapshot.builder().create(), Snapshot.open(), and handle.snapshot().
snap.path
snap.digest
sha256:hex). The snapshot’s identity.
snap.sizeBytes
snap.imageRef
snap.imageManifestDigest
snap.format
snap.scope
"disk" for a disk-only snapshot, "resumable" once resumable snapshots land. Always "disk" today. See SnapshotScope.
snap.fstype
"ext4").
snap.parent
null for a root.
snap.createdAt
snap.labels
[key, value] pairs.
snap.sourceSandbox
null when the manifest has no source recorded.
snap.verify()
Example
Example
upper.kind is "notRecorded" when the manifest has no integrity hash recorded.
Returns
Verification result.
SnapshotBuilder
Fluent builder for a snapshot, returned bySnapshot.builder(name). Every setter mutates in place and returns this, so calls chain. The source sandbox is required: call .fromSandbox() before .create().
.fromSandbox()
.create() fails without it.
Parameters
sourceSandboxstringName of the stopped sandbox to capture.
.destDir()
destDir/<name>; the name stays the snapshot’s identity either way.
Parameters
destDirstringParent directory to create the artifact in (e.g. a larger volume).
.label()
key=value label to the snapshot manifest. May be called repeatedly.
Parameters
keystringLabel key.
valuestringLabel value.
.force()
.recordIntegrity()
.resumable()
"resumable" snapshot (disk plus VM state). Accepted by the builder, but .create() currently returns an Unsupported error; resumable snapshots have not landed yet.
.create()
Example
Example
Returns
The created snapshot artifact.
Types
SnapshotHandle class
Lightweight handle backed by an index row. Values are snapshotted from the index at construction time; callSnapshot.get() again for a fresh reading if needed. Handles from Snapshot.list() are read-only and throw on open() / remove(); fetch a live handle via Snapshot.get() for those lifecycle methods.
Returned by Snapshot.get(), Snapshot.list(), Snapshot.load()
snapshotHandle.open()
Snapshot.list()); fetch a live handle via Snapshot.get() first.
snapshotHandle.remove()
force is set. Throws if this handle is read-only.
SaveOpts interface
Bundle options forSnapshot.save(). All fields default to false.
Used by Snapshot.save()
SnapshotScope type
Scope of what a snapshot captures. Every snapshot today is"disk"; "resumable" (disk plus VM state) is reserved for resumable snapshots.
Returned by snap.scope · SnapshotHandle.scope
SnapshotVerifyReport union
Result ofsnap.verify(). The upper discriminant is "notRecorded" when no integrity hash was stored at create time, or "verified" when the recorded hash matched the recomputed one.
Returned by snap.verify()