How to Manage VMware Snapshots

What is a VMware snapshot?

VMware snapshots are quick and easy way to save a state of a virtual machine (VM) before you test a patch, software update or other change. The VMware snapshot preserves the state and data of the VM at the current point in time, so when you are done testing, you can quickly revert the VM back to a desired state.

You can create a snapshot file with or without memory. A memory snapshot also captures the memory state of the VM and its power settings. If you create a snapshot without memory and revert to that snapshot, you will have to start the VM manually.

If you want to quiesce the guest file system, the VM has to have VMware tools installed. Quiescing flushes dirty buffers from the OS’s in-memory cache to disk.

Snapshots are not intended to be used as a backup strategy.

What files are created when I take a snapshot?

When you take a snapshot, the operation triggers the creation of the following files:

.vmdk, -delta.vmdk, .vmsd and .vmsn files.

  • .vmdk file — This is a machine file to which the guest operating system (OS) can write.
  • -delta.vmdk — A delta disk (also called child disk) is the difference between the current state of the virtual disk and the state that existed at the time that the previous snapshot was taken. The delta disk is composed from two files: a small descriptor file and a file that contains the raw data. The descriptor and flat files are also called redo logs.
  • .vmsn file — This is an optional file that saves the memory of the VM. As explained above, if you don’t capture the state of memory, the “revert to snapshot” operation will restore the virtual machine to a non-running state and it will have to be restarted manually.
  • .vmsd file — This is a database file that contains VMs snapshot information and all the relationships between snapshots and between delta disks for each snapshot.

How do I manage VMware snapshots?

You can use the vSphere web client to take new snapshots, delete snapshots and more. Here are all the options:

  • Create Snapshot — Creates a new snapshot of a virtual machine, which becomes the current snapshot. You can take a snapshot when a virtual machine is powered on, powered off or suspended.
  • Remove Snapshot — Removes a snapshot and deletes any associated storage.
  • Remove All Snapshots — Removes all snapshots associated with a virtual machine. If the virtual machine does not have any snapshots, this operation simply returns successfully.
  • Revert to Snapshot — Changes the execution state of a virtual machine to the state of the selected snapshot. This is the same as the “Go To” option under the Snapshot Manager in the vSphere/VI client.
  • Revert to Latest Snapshot — Reverts to the most recent snapshot for the VM.
  • Consolidate — Merges the hierarchy of redo logs. This is supported in vSphere 5.0 and later.

How do I create a snapshot?

1. Access the VMware vSphere snapshot manager by right-clicking on a VM, and then click Create Snapshot. Alternatively, you can select VM > Actions > Snapshots > Take snapshot.

Taking a VMware vSphere snapshot

2. In the pop-up window, enter a name and description for the snapshot. It is recommended to include a detailed description of what has been done to the VM or how the VM is configured.

3. If you check the “Snapshot the virtual machine’s memory” option, the snapshot will also record the VM’s memory. If you check this box and the VM is running when you take a snapshot, the icon of the snapshot will be green.

Adding description to VMware vSphere snapshot

4. Click OK to create the snapshot.

How do I revert to a snapshot?

The figure below shows several snapshots to choose from. If we revert to a snapshot with a green icon, the VM will be in running state.

Reverting a VMware vSphere snapshot

1. To revert to a snapshot, from the snapshot manager, choose one of the snapshots (for example Patch 2) and click Revert To.

Reverting a VMware vSphere snapshot from the snapshot manager

2. Click OK.

3. Note that you’ll get a message saying that the “current state of the virtual machine will be lost unless it is saved in a snapshot.” This means that if you have made any changes to the VM and have not saved them by creating a snapshot, your work will be lost. If you’re ready to proceed, click OK.

Reverting a VMware vSphere snapshot Message

4. The snapshot manager screen will indicate where you are within the snapshot tree. Click Since the Patch 2 snapshot does not have the machine’s memory, you will have to start the VM manually.

Managing VMware vSphere snapshots

VMware snapshot best practices

VM snapshots take up significant space, so you should limit yourself to 2 or 3 of them.

It’s fine to use snapshots on test or dev VMs, but don’t use them on production VMs. A VM with snapshots usually has bad performance because you are doubling IOPS and there is CPU overhead in calculating the block-level difference. The performance degradation is based on how long the snapshot or snapshot tree has been in place, the depth of the tree, and how much the VM and its guest operating system (OS) have changed from the time you took the snapshot.

As noted earlier, snapshots are not meant to be a method of backup and recovery. Always use a proper backup software solution in your datacenter.

Snapshot manager can detect snapshots for individual VMs only. Third-party solutions are available that enable you to see and manage snapshots for multiple VMs, which gives you better control over your virtual environment. For example, you can quickly spot and investigate unauthorized creation or deletion of snapshots across your virtual environment.

Final words

Snapshots are a cool virtualization technology, but they should be used sparingly and with caution. Keep in mind that if you store sensitive or regulated information on your VMs, you need to manage your snapshots properly to avoid security and compliance issues.