Skip to main content
A snapshot captures the full filesystem and memory state of a running capsule and saves it as a named template. You can then boot any number of new capsules from that template, each starting with the same pre-configured environment — installed packages, populated databases, cloned repositories, or whatever state you baked in.

Create a snapshot

Call create_snapshot on a running capsule. The snapshot is named with the string you provide, and returns a Template object:
template = capsule.create_snapshot(name="my-template", overwrite=True)
print(template.name)  # "my-template"
Creating a snapshot pauses the capsule and destroys it as part of the snapshotting process. The capsule is not available after create_snapshot returns. Use snapshots to bake environment state, not as a live backup of a running session.

Use the snapshot as a template

Once created, the snapshot name is available as the template parameter for any new capsule:
from wrenn import Capsule

with Capsule(template="my-template", wait=True) as capsule:
    result = capsule.commands.run("python --version")
    print(result.stdout)
Every capsule created from the same snapshot starts with an identical environment.

Manage snapshots with the low-level client

For bulk operations or when you need more control, use WrennClient directly:
from wrenn import WrennClient

with WrennClient() as client:
    # Create a snapshot from an existing capsule ID
    template = client.snapshots.create(capsule_id="cl-abc123", name="my-snap")

    # List all snapshots for the team
    templates = client.snapshots.list()
    for t in templates:
        print(t.name)

    # Delete a snapshot by name
    client.snapshots.delete("my-snap")
Name snapshots descriptively to reflect what they contain — for example, python-3.12-numpy-pandas or app-v2-seeded-db. Use overwrite=True to update an existing template in-place without changing the name all dependent capsules reference.