Virtual Machine Snapshot
A virtual machine snapshot is an image of a virtual machine's disk at a specific point in time. It's a read-only copy that can be used to create a new virtual machine or restore a VM to a previous state. Essentially, it's a backup mechanism and a templating tool rolled into one.
You can create two types of VM snapshots in Private Cloud Director.
Type 1 - VM Ephemeral Disk Snapshot
This type of snapshot is created when you take a snapshot of a virtual machine that is using an ephemeral disk as it's root disk. A new image gets created in the Image Library that captures the point in time state of the VM's disk, including its data and configuration, at the moment the snapshot is taken.
Snapshot File Type & Location
- Ephemeral disk snapshots are always of type
qcow2
- They are always stored in the Image Library Service as a single
qcow2
file.
Note that if a VM is created with ephemeral root disk, and then mounts one or more block storage volumes as data volumes, taking a snapshot of such a VM will only create a snapshot of it's root disk. The data volumes will not be snapshotted or tracked as part of the VM snapshot. To fully recreate such VM using a snapshot in the future, you need to first snapshot the VM and then separately take a volume snapshot of the data volumes. Then during VM restore or recreation time, you can create a new VM first using the VM snapshot, and then mount the volumes data volumes on this VM using the volume snapshots you created above.
Taking a snapshot of a VM with ephemeral root disk will only snapshot the root disk. Any volumes attached to the VM will NOT be included in the snapshot.
Live Snapshots
A snapshot is considered live when taken against a running virtual machine with no downtime.
Such snapshot is simply disk-only snapshot and as such is guaranteed to be crash consistent but not application consistent.
When you issue the command to create a snapshot of a running VM, the Private Cloud Director compute service informs the hypervisor to freeze the VM to allow the creation of a “delta” file before resuming the execution of the VM. This is done to prevent the VM from writing directly to its disk while the disk is copied. VM continues to write to the delta file while the VM disk is being copied. When the copy is done, the VM is frozen again to allow the “delta” to be merged with the VM's disk, and the execution is then resumed with the disk fully merged.
Inconsistencies can appear on the first freeze if the VM is not aware that the hypervisor is taking a snapshot, because the applications and the kernel running on the instance are not told to flush their buffers.
For applications requiring strict data consistency, it is recommended to either shut down the VM or use application-level mechanisms to ensure data is flushed to disk before taking the snapshot.
Live VM snapshots are disk-only snapshots and may not capture the in-memory state of applications. For applications requiring strict data consistency, it is recommended to either shut down the VM or use application-level mechanisms to ensure data is flushed to disk before taking the snapshot.
Type 2 - VM Volume Snapshot
This type of snapshot is created when you snapshot a virtual machine that is using a volume for it's root disk. When you snapshot such a virtual machine:
Snapshot File Type and Location
- The VM's root disk volume is snapshotted as a bootable volume snapshot.
- If the VM has any other volumes mounted, those volumes are also snapshotted.
- The Image Library service creates a metadata entry in the Image Library database that tracks a reference to the root volume snapshot and the data volume snapshots, along with other required information.
- No other file gets created or stored in the Image Library for this snapshot.
When a new VM gets created using this snapshot, the Image Library service will use the metadata stored in the database behind the scenes to identify the root volume snapshot and the data volume snapshots if any. This information will then be supplied to the Compute Service which will then use those snapshots to create a new VM.
Snapshot Creation
You can take a snapshot of virtual machines in running or powered off state. In the UI, select the snapshot action for the VM to take the snapshot.
Snapshot Properties
All VM snapshots will have the image_type=snapshot
property set. You can view this property in the properties column.