Skip to main content

Boot Instance from Snapshot

Boot an instance directly from a snapshot to quickly restore a saved state or create new instances based on existing snapshots. This is particularly useful for scaling applications, creating development environments, restoring from backups, or resizing snapshots with different resource specifications. Note that booting is equivalent to turning a computer on/off - it doesn't preserve running process state like pause/resume does.

Boot Instance from Snapshot

from morphcloud.api import MorphCloudClient

client = MorphCloudClient()

# Boot instance from snapshot with default settings
snapshot_id = "snapshot_your_snapshot_id" # Replace with a valid snapshot ID
instance = client.instances.boot(snapshot_id=snapshot_id)

print(f"Instance ID: {instance.id}")
print(f"Instance Status: {instance.status}")

Boot with Custom Resource Specifications

You can override the snapshot's default resource specifications when booting:

from morphcloud.api import MorphCloudClient

client = MorphCloudClient()

snapshot_id = "snapshot_your_snapshot_id" # Replace with a valid snapshot ID

# Boot with custom resource specifications
instance = client.instances.boot(
snapshot_id=snapshot_id,
vcpus=4, # Override CPU cores
memory=4096, # Override memory (MB)
disk_size=20480, # Override disk size (MB)
)

print(f"Instance ID: {instance.id}")
print(f"vCPUs: {instance.spec.vcpus}")
print(f"Memory: {instance.spec.memory}MB")
print(f"Disk Size: {instance.spec.disk_size}MB")

Boot with Time-to-Live (TTL) Settings

Set automatic expiration for instances by configuring TTL settings:

from morphcloud.api import MorphCloudClient

client = MorphCloudClient()

snapshot_id = "snapshot_your_snapshot_id" # Replace with a valid snapshot ID

# Boot instance with TTL settings
instance = client.instances.boot(
snapshot_id=snapshot_id,
ttl_seconds=3600, # Instance expires in 1 hour
ttl_action="pause" # Pause instead of stop when TTL expires
)

print(f"Instance ID: {instance.id}")
print(f"TTL: 1 hour (will be paused when expired)")

Best Practices

  • Verify snapshot exists before attempting to boot
  • Set appropriate TTL to avoid unexpected costs
  • Use custom resources only when necessary
  • Monitor boot status for mission-critical instances

Booting from snapshots provides a quick way to create instances with pre-configured states, ideal for scaling applications and restoring from backups.