Create and use snapshots
This guide shows you how to create snapshots from disks, create new disks from snapshots, and manage snapshots using the evroc CLI and API.
Prerequisites
- evroc CLI installed and configured
- At least one existing disk in your project
Create a snapshot
You can create a snapshot from any existing disk. The disk can be attached to a VM or detached, and the VM can be running or stopped.
Important: You can create a snapshot while the VM is running, but there's a risk the snapshot may be corrupted if the guest OS is writing to the disk. To minimise this risk, if this is a data disk, use
fsfreezeinside the VM to quiesce the filesystem before creating the snapshot. Do not freeze your boot disk - this is very dangerous and will break your VM. To usefsfreeze:sudo fsfreeze -f /mnt/mydisk # Create the snapshot here sudo fsfreeze -u /mnt/mydisk
Create a snapshot using the CLI
evroc compute snapshot create mysnapshot \
--disk-ref=my-disk
Create a snapshot using the API
curl -X POST https://api.evroc.com/compute/v1beta2/projects/{projectID}/regions/{regionName}/snapshots \
-H "Content-Type: application/json" \
-d '{
"metadata": { "name": "mysnapshot" },
"spec": {
"diskRef": "/compute/projects/{projectID}/regions/{regionName}/disks/my-disk"
}
}'
See Create a Snapshot in the API reference.
List snapshots
List all snapshots in your project:
evroc compute snapshot list
Use evroc compute snapshot get <snapshot_name> for detailed information, including restoreSize and creation time.
See List Snapshots in the API reference.
Create a disk from a snapshot
You can create a new disk from any existing snapshot. The new disk is created in the same zone as the snapshot.
Create a disk from a snapshot using the CLI
evroc compute disk create mynewdisk \
--snapshot=mysnapshot \
--zone=a
If you don't specify a disk size, it defaults to the snapshot's restoreSize. If you specify a size, it must be greater than or equal to the restoreSize.
Important: If the new disk is has not ever been attached to a VM, the snapshot you created it from can't be deleted until the disk is deleted.
Create a disk from a snapshot using the API
curl -X POST https://api.evroc.com/compute/v1beta1/projects/{projectID}/regions/{regionName}/disks \
-H "Content-Type: application/json" \
-d '{
"metadata": { "name": "mynewdisk" },
"spec": {
"source": {
"type": "snapshot",
"snapshotRef": "/compute/projects/{projectID}/regions/{regionName}/snapshots/mysnapshot"
},
"placement": { "zone": "a" }
}
}'
See Create a Disk in the API reference.
Delete a snapshot
Delete a snapshot you no longer need. The snapshot can't be deleted if a detached disk was created from it.
evroc compute snapshot delete mysnapshot
See Delete a Snapshot in the API reference.
Next steps
- Learn how to restore a VM from a snapshot
- Learn how to attach the new disk to a VM
- Learn how to resize disks