Snapshot of virtual machines

A snapshot is a view of a virtual machine’s operating system and applications on any or all available disks at a given point in time. An administrator may take a snapshot of a virtual machine before making changes to it. This can protect against errors that might have unintended consequences. If there is a problem, the administrator can revert the state of the virtual machine to one recorded by the snapshot.

Red Hat Virtualization allows you to take live snapshots of running virtual machines as well as snapshots of stopped virtual machines. RHVM supports several snapshots of a virtual machine’s state, but it can only use a single snapshot at a time.

You can shut down the virtual machine and permanently roll the disk image back to an earlier snapshot. When you do, RHVM discards all snapshots taken at later points in time. Before committing to the rollback, you can temporarily preview a particular snapshot by booting it to confirm that it is the one you want to use.

Snapshots can also be used to create new virtual machines. You can clone a virtual machine from an older snapshot rather than cloning directly from a current virtual machine. A clone is a copy of that virtual machine on new hardware. The advantage and disadvantage of this are that it may have machine-specific data and configuration settings from the old virtual machine in the new virtual machine. As an alternative, you can use a snapshot to create a “sealed template” that can be used to create virtual machines from an image that has had this machine-specific information cleared.

Creating a Snapshot of a virtual machine

Red Hat Virtualization allows you to manually create snapshots for virtual machines with the Administration Portal. A virtual machine needs the RHV guest agent to create a consistent snapshot.

The following procedure details how to create a snapshot for a virtual machine using the administration portal.

1. In the Virtual Machines tab, right-click the source virtual machine of the snapshot. Select Create Snapshot from the menu. A window titled Create Snapshot appears.

2. In the Create Snapshot window, enter a description for the snapshot in the Description field. In the Disks to include section, select the disks you want to include in the snapshot.

If the virtual machine is running, you may select the Save Memory check box to save the virtual machine’s memory state in the snapshot. The resulting snapshot looks like a suspended version of the virtual machine.

Click OK to create the snapshot.

Create Snapshot window

3. Watch the Snapshots tab, and verify that the value for the snapshot’s Status field is OK. It may take a minute or so for this value to transition from Locked to OK.

Snapshot status

Rolling back to an earlier snapshot

Once you have a snapshot, you can shut down the original virtual machine and relaunch it using the earlier snapshot. You have the option to preview the snapshot before committing to the rollback. In this mode, the virtual machine runs using the virtual image of the snapshot. This allows you to confirm that you have the right snapshot selected.

When you are ready, you can permanently commit to the rollback. When you do this, the active image for the virtual machine reverts to that snapshot, and all snapshots newer than the one selected for rollback are permanently discarded.

To preview and roll back a virtual machine state using a snapshot:
1. In the Administration Portal, click the Virtual Machines tab. Select your virtual machine from the list, and make sure that it has been shut down.

2. Select the Snapshots tab for your virtual machine at the bottom of the interface. Find the snapshot you want to restore and select it from the list.

3. Click the Preview item. If the snapshot has saved the memory state, a window opens noting this and asking if you want to restore memory. The snapshot moves to the state In Preview, which indicates that it’s ready to run.

4. At this point, you have the option of running the preview on a temporary basis. Simply Run the virtual machine. When you have decided whether or not to roll back to that snapshot, you can shut down the virtual machine again.

5. If you have decided to roll back to that snapshot permanently, click the Commit item on the Snapshots tab. This rolls your virtual machine’s state back to that snapshot on a permanent basis, and discards any snapshots newer than the one you rolled back to. You can then Run the virtual machine normally to restart it.

Alternatively, if you decide not to roll back to that snapshot, click the Undo item on the Snapshots tab. The snapshot changes state from In Preview to OK, and your original image changes state from Locked to OK. Again, you can now run the virtual machine normally, or you can try rolling back to a different snapshot.

NOTE: The decision to commit to a particular snapshot is irreversible. The formerly current image state, and any snapshot newer than the snapshot you committed, and all data unique to them, is permanently lost.

Cloning a virtual machine from a snapshot

Any existing snapshot can be used to clone a virtual machine. Remember, a clone is a copy of that virtual machine created on new hardware. It can be useful to create a clone from a snapshot instead of a current virtual machine if you want to make a copy of some older state of that virtual machine.

To clone a virtual machine from an existing snapshot:

1. In the Administration Portal, switch to the Virtual Machines tab. Select your virtual machine from the list.

2. Select the Snapshots tab for your virtual machine at the bottom of the interface. Find the snapshot you want to clone and select it from the list.

3. Click the Clone item. This opens a new window, Clone VM from Snapshot, which is very similar to the New Virtual Machine window. At a minimum, set a Name for the cloned virtual machine. You can customize other details as well. Then click OK to create the cloned virtual machine.

Watch the virtual machine’s status on the Virtual Machines tab. Once its status switches to Down, you may run the new machine.

NOTE: A cloned virtual machine may still have data from its source image. You might not want this if you’re trying to create a new virtual machine with a similar configuration rather than an exact copy. As an alternative, you can use the snapshot to create a sealed template that has been cleared of unique data, and then create virtual machines from that template. A template can be created from a snapshot by using the Make Template item instead of Clone

Deleting a Snapshot

The following procedure details how to delete a snapshot using the Administration Portal.

1. In the Virtual Machines tab, select the row for the virtual machine associated with the snapshot. At the bottom of the interface, select the Snapshots tab. Select the snapshot to delete, and click Delete.

Snapshot to delete

2. A window titled Delete Snapshot opens to confirm that you want to permanently remove that snapshot. If you do, click OK to delete the snapshot.

3. In the Snapshots tab, verify that the snapshot is no longer displayed. It may take a minute or so to delete the snapshot.