Skip to main content

What's a Snapshot?

Snapshots are immutable point-in-time copies of both memory and disk state. They serve as templates for starting instances. When you take a snapshot, it captures the complete state of a running instance, including all running processes and services.

Create a New Snapshot

To create a new snapshot, specify the resource specifications like vcpus, memory, and disk_size. You can optionally include a digest. The API will use our default image morphvm-minimal automatically.

from morphcloud.api import MorphCloudClient

client = MorphCloudClient()

new_snapshot = client.snapshots.create(
vcpus=2,
memory=4096, # MB
disk_size=50000, # MB
digest="digest" # Optional
)

print(f"Snapshot created with ID: {new_snapshot.id}")

List Snapshots

You can retrieve a list of all snapshots in your Morph Cloud account.

from morphcloud.api import MorphCloudClient

client = MorphCloudClient()

# List all snapshots
snapshots = client.snapshots.list()

for snapshot in snapshots:
print(f"ID: {snapshot.id}, Created At: {snapshot.created}")

Get Snapshot Details

To get detailed information about a specific snapshot, use its ID.

from morphcloud.api import MorphCloudClient

client = MorphCloudClient()

snapshot_id = "snapshot_abc123"
snapshot = client.snapshots.get(snapshot_id=snapshot_id)

print(f"Snapshot ID: {snapshot.id}")
print(f"Created At: {snapshot.created}")

Delete a Snapshot

When you no longer need a snapshot, you can delete it.

from morphcloud.api import MorphCloudClient

client = MorphCloudClient()

snapshot_id = "snapshot_abc123"
client.snapshots.delete(snapshot_id=snapshot_id)

print(f"Snapshot {snapshot_id} has been deleted")