Snapshots
Snapshots let you create a point-in-time capture of a running sandbox, including its in-memory execution state and writable disk state.
You can then restore that snapshot into a brand new sandbox that starts from the same checkpoint.
How snapshots behave
Section titled “How snapshots behave”- Snapshots are created from a
runningsandbox. - The VM is paused while the snapshot is taken and uploaded.
POST /v1/sandbox/{sandboxID}/snapshot/createresumes the source sandbox after the snapshot finishes.POST /v1/sandbox/{sandboxID}/snapshot/pausecreates a named snapshot and then terminates the source sandbox.POST /v1/sandbox/{sandboxID}/pausepauses the sandbox without creating a named snapshot. See Sandboxes.- If you omit
name, Leap0 generates one from the template name.
Restore behavior
Section titled “Restore behavior”Restoring a snapshot creates a brand new sandbox.
- Compute settings come from the snapshot, not the restore request.
- The snapshot’s template is reattached automatically.
timeout_mincan be overridden when restoring.auto_pausecan be enabled when restoring if you want the new sandbox to pause itself at timeout.network_policydefaults to the snapshot values, but you can override it on restore.- Restore requests address snapshots by
snapshot_name.
Create a snapshot
Section titled “Create a snapshot”from leap0 import Leap0Client
client = Leap0Client()sandbox = client.sandboxes.create()snapshot = client.snapshots.create(sandbox, name="workspace-warm")
print(snapshot.id, snapshot.name)import { Leap0Client } from "leap0"
const client = new Leap0Client()const snapshot = await client.snapshots.create("<sandbox_id>", {name: "workspace-warm",})
console.log(snapshot.id, snapshot.name)await client.close()Snapshot and terminate a sandbox
Section titled “Snapshot and terminate a sandbox”Use this when you want to create a named snapshot and shut the sandbox down immediately after the snapshot is stored.
The response includes the snapshot details and confirms the sandbox state is paused.
from leap0 import Leap0Client
client = Leap0Client()sandbox = client.sandboxes.create()snapshot = client.snapshots.pause(sandbox, name="workspace-warm")
print(snapshot.id, snapshot.name)import { Leap0Client } from "leap0"
const client = new Leap0Client()const snapshot = await client.snapshots.pause("<sandbox_id>", {name: "workspace-warm",})
console.log(snapshot.id, snapshot.name)await client.close()Restore a snapshot
Section titled “Restore a snapshot”from leap0 import Leap0Client, NetworkPolicyMode
client = Leap0Client()sandbox = client.snapshots.resume( snapshot_name="workspace-warm", auto_pause=True, timeout_min=30, network_policy={ "mode": NetworkPolicyMode.CUSTOM, "allow_cidrs": ["1.2.3.4/32"], },)
print(sandbox.id, sandbox.state)import { Leap0Client, NetworkPolicyMode } from "leap0"
const client = new Leap0Client()const sandbox = await client.snapshots.resume({snapshotName: "workspace-warm",autoPause: true,timeoutMin: 30,networkPolicy: { mode: NetworkPolicyMode.CUSTOM, allowCidrs: ["1.2.3.4/32"],},})
console.log(sandbox.id, sandbox.state)await client.close()Delete a snapshot
Section titled “Delete a snapshot”When a snapshot is deleted, all stored data for that sandbox (memory state, disk state) is permanently removed.
from leap0 import Leap0Client
client = Leap0Client()client.snapshots.delete("<snapshot_id>")import { Leap0Client } from "leap0"
const client = new Leap0Client()await client.snapshots.delete("<snapshot_id>")await client.close()