Snapshots let you capture a Sandbox filesystem as an immutable artifact, then restore it into new Sandboxes or turn it into a reusable base image. Use snapshots when you want to:
  • Fork Sandboxes to test different variations of code
  • Initialize Sandboxes with existing state for faster cold starts
  • Save a reproducible environment you can return to later
Snapshots capture filesystem state only, so running processes and environment variables are not preserved. Memory snapshots will be released in early September 2025.

Creating a Snapshot

from beam import Image, Sandbox

# Create a sandbox and make some changes to the filesystem
sandbox = Sandbox(cpu=1).create()
p = sandbox.process.exec("sh", "-c", "mkdir -p /something && touch /something/file.txt")

# Read the logs
p.wait()
print(p.logs.read())

# Generate a filesystem snapshot and terminate the sandbox
snapshot_id = sandbox.snapshot()
sandbox.terminate()

Restoring a Snapshot

from beam import Image, Sandbox

# Create a new sandbox and restore the snapshot
sandbox = Sandbox().create_from_snapshot(snapshot_id)

# This sandbox uses the filesystem state from the snapshot created above
p = sandbox.process.exec("ls", "-l", "/something")

p.wait()
print(p.logs.read())

sandbox.terminate()

Creating Base Images from Snapshots

You can use Snapshots as a base image for any other abstraction or Sandbox on Beam, using Image.from_snapshot:
from beam import Image, Sandbox

# Creates an image from a snapshot
image = Image().from_snapshot(snapshot_id)

sandbox = Sandbox(image=image).create()
p = sandbox.process.exec("ls", "-l", "/something")

p.wait()
print(p.logs.read())

sandbox.terminate()