«

»

Jan 16

Virtual Machine Snapshots – BE CAREFUL!!!

Recently had a customer that was experiencing some performance issues and had a datastore that was low on space. The cause ended up being a large virtual machine snapshot that was too large to consolidate due to a lack of space on the datastore.

The issues was caused by a snapshot created by their backup software that had not been committed after the backup job completed. This is a common issue, at least I have seen this happen fairly often. The snapshot continued to grow and had become so large that it was causing performance issues with the VM and could not be deleted due to the lack of space on the datastore.

Snapshots are a great tool but it is important that you monitor the snapshots to ensure they do not grow too large. This post covers some different options that are available for monitoring snapshot usage.

Creating a Snapshot Alarm
An alarm can be created to display a warning or alert on a virtual machine if a snapshot grows to be larger than a threshold set in an alarm trigger.

To create a VM snapshot alarm for all virtual machines in a vCenter’s inventory select the vCenter Server. In the Manage tab select Alarm Definitions and click Add to start the Alarm Definition wizard. Give the alarm and name and description.
snapshotalarm1

Add a new Trigger and select VM Snapshot Size for the Trigger.
snapshotalarm2

Set the Warning Condition to the snapshot size in GB that should trigger a warning, in this example the size is set to 10 GB. Set the Critical Condition to the snapshot size in GB that should trigger a critical alert, in this example the size is set to 15 GB.
snapshotalarm3

An action can be configure to send an email to an administrator if a warning or critical alarm is triggered.
snapshotalarm4

The new VM Snapshot Size alarm is added to the alarm definitions.
snapshotalarm5

If a snapshot grows to a size larger than what has been configured the alarm is triggered and the warning or alert is displayed on the VM and in the Alarms box in the Web Client.
snapshotalram

Using Storage Reports
Snapshot size can also be monitored using Storage Reports using the vSphere Web Client. To view Snapshot Size using the Storage Reports select the Datacenter or Host in vCenter inventory. On the Monitor tab select Storage Reports. The snapshot size for each virtual machine will be shown in the Snapshot Space column.
snapstorageviews
This information can be viewed using the vSphere Client on the Storage View tab.

Using PowerCLI
PowerCLI can also be used to identify virtual machines with snapshots using the Get-Snapshot cmdlet.

$vmlist = Get-VM

foreach ( $vm in $vmlist ) 
{
 $snapshots = Get-Snapshot -VM (Get-VM -Name $vm.Name)

  if ( $snapshots -ne $null ) 
  {
    write-host "Snapshot found!" -ForegroundColor Red
    foreach ( $snap in $snapshots )
    {
      write-host "VM:" $vm.Name 
      write-host "Snapshot:" $snap.Name
      write-host "Size:" $snap.SizeMB 
      write-host "Created:" $snap.Created
    }
  }

}

When executed the PowerCLI code displays the Virtual Machine name, the Snapshot name, the Snapshot size in MB, and the date the Snapshot was created.
powerclisnapshot

The ability to take a snapshot of a virtual machine is a handy tool for administrators but snapshots can cause a number of issues if they are not used correctly. Hopefully the options in the post will help you manage snapshots in your environment.

Constructive comments and suggestions are always welcome.

About the author

vHersey

Hersey Cartwright is an IT professional with extensive experience designing, implementing, managing, and supporting technologies that improve business processes. Hersey is Solutions Architect for SimpliVity covering Virginia, Washington DC, and Maryland. He holds the VMware Certified Design Expert (VCDX-DV #128) certification. Hersey actively participates in the VMware community and was awarded the VMware vExpert title in 2016, 2015, 2014, 2013, and 2012. He enjoys working with, teaching, and writing about virtualization and other data center technologies. Follow Hersey on Twitter @herseyc

1 comment

  1. Jim Millard

    Brilliant. Too bad they don’t a) predefine this; b) have a “snapshot count” trigger; and c) MB units for the size trigger.

    Why would I want the latter two? Because backup systems can stack up a crap-tonne of snapshots without ever hitting the 1G minimum threshold. I don’t know about you, but >2 stacked snapshots on a non-VDI VM is probably a bad idea, whether they’re big or not.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

four × 4 =