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
- Python
- TypeScript
- CLI
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}")
import { MorphCloudClient } from 'morphcloud';
const client = new MorphCloudClient();
async function bootFromSnapshot() {
const snapshot_id = "snapshot_your_snapshot_id"; // Replace with a valid snapshot ID
const instance = await client.instances.boot({ snapshot_id: snapshot_id });
console.log(`Instance ID: ${instance.id}`);
console.log(`Instance Status: ${instance.status}`);
}
bootFromSnapshot();
# Boot instance from snapshot
morphcloud snapshot boot snapshot_your_snapshot_id
Boot with Custom Resource Specifications
You can override the snapshot's default resource specifications when booting:
- Python
- TypeScript
- CLI
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")
import { MorphCloudClient } from 'morphcloud';
const client = new MorphCloudClient();
async function bootWithCustomSpecs() {
const snapshot_id = "snapshot_your_snapshot_id"; // Replace with a valid snapshot ID
// Boot with custom resource specifications
const instance = await client.instances.boot({
snapshot_id: snapshot_id,
vcpus: 4, // Override CPU cores
memory: 4096, // Override memory (MB)
disk_size: 20480, // Override disk size (MB)
});
console.log(`Instance ID: ${instance.id}`);
console.log(`vCPUs: ${instance.spec.vcpus}`);
console.log(`Memory: ${instance.spec.memory}MB`);
console.log(`Disk Size: ${instance.spec.disk_size}MB`);
}
bootWithCustomSpecs();
# Boot with custom resource specifications
morphcloud snapshot boot snapshot_your_snapshot_id \
--vcpus 4 \
--memory 4096 \
--disk-size 20480
Boot with Time-to-Live (TTL) Settings
Set automatic expiration for instances by configuring TTL settings:
- Python
- TypeScript
- CLI
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)")
import { MorphCloudClient } from 'morphcloud';
const client = new MorphCloudClient();
async function bootWithTTL() {
const snapshot_id = "snapshot_your_snapshot_id"; // Replace with a valid snapshot ID
// Boot instance with TTL settings
const instance = await 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
});
console.log(`Instance ID: ${instance.id}`);
console.log("TTL: 1 hour (will be paused when expired)");
}
bootWithTTL();
# Boot instance with TTL settings
morphcloud snapshot boot snapshot_your_snapshot_id \
--ttl-seconds 3600 \
--ttl-action pause
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.