Skip to content

Snapshots

Capture a sandbox and create new sandboxes from it.

A snapshot captures the state of a sandbox. You can create any number of new sandboxes from it.

Not available yet.

Not available yet.

Not available yet.

import { Sutra } from "@mistrive/sutra";

const sutra = new Sutra({
  baseUrl: "https://anchor.jgcp.mistrivedev.com",
});

const sandbox = await sutra.sandboxes.create();
await sandbox.processes.run({ shellCommand: "pip install requests" });

// Capture the sandbox's disk.
const snapshot = await sutra.snapshots.create({
  sourceSandbox: sandbox.name,
  includes: "DISK",
});

// The snapshot outlives its sandbox.
await sandbox.delete();

// Create new sandboxes from it, as many as you need.
const copy = await sutra.sandboxes.create({ source: { snapshot: snapshot.name } });
const result = await copy.processes.run({ argv: ["pip", "show", "requests"] });
console.log(result.stdout);
from mistrive.sutra import Sutra

sutra = Sutra(
    base_url="https://anchor.jgcp.mistrivedev.com",
)

sandbox = sutra.sandboxes.create()
sandbox.processes.run(shell_command="pip install requests")

# Capture the sandbox's disk.
snapshot = sutra.snapshots.create(source_sandbox=sandbox.name, includes="DISK")

# The snapshot outlives its sandbox.
sandbox.delete()

# Create new sandboxes from it, as many as you need.
copy = sutra.sandboxes.create(source={"snapshot": snapshot.name})
result = copy.processes.run(argv=["pip", "show", "requests"])
print(result.stdout)
#!/usr/bin/env bash
set -euo pipefail

# Assumes you ran `sutra auth login` (see the Quickstart).
sutra sandboxes create demo
sutra processes run demo -- pip install requests

# Capture the sandbox's disk.
sutra snapshots create demo-deps --sandbox demo --includes disk

# The snapshot outlives its sandbox.
sutra sandboxes delete demo

# Create new sandboxes from it, as many as you need.
sutra sandboxes create copy --snapshot demo-deps
sutra processes run copy -- pip show requests

What a snapshot includes

Set includes when you create a snapshot:

Value What the snapshot holds
VOLUMES The sandbox’s volumes.
DISK Its whole disk.
MEMORY Its disk and memory, so processes continue where they were.

These are the same levels a stopped sandbox reports in preserved. Each snapshot records the sandbox it came from, its size and, if it has one, the time it expires.

Restore and fork

There is no separate restore call. To go back to a snapshot, create a sandbox with source.snapshot. To fork, do the same several times: each new sandbox starts from the same state and then runs on its own.

Lifetime

A snapshot outlives its sandbox. Deleting the sandbox does not delete its snapshots. Delete a snapshot when you no longer need it.

You can also build a template version from a snapshot, so the state you captured becomes a named environment.

Type to search…

↑↓ navigate↵ selectEsc close