Posted by: Eric Siebert
Eric Siebert, ESX, Snapshots, virtual machine, VMware
In a VMware snapshot series I wrote a few months ago (How VMware snapshots work, Deleting virtual machine snapshots without wasting disk space and Troubleshooting VMware snapshots), I listed a few methods for finding snapshots that are running in your environment. I thought I would expand on those methods and also offer some new methods for finding snapshots. Snapshots are a handy tool but leaving them running for any longer then necessary is not a good idea, (read the snapshot series for an explanation).
VMware’s vCenter Server does not provide a centralized mechanism for managing snapshots so subsequently you must resort to other methods if you want to find them. Let’s review the various methods that you can use to find snapshots. If you know how to find them, you’ll be aware of snapshots that are still running and won’t be (as) surprised later when your volumes run out of disk space.
The first method is fairly simple and relies on the find command that is part of the VMware ESX service console. To use it, log in to the service console, switch to your VMFS volume directory and type the following command. The command will find all files that have ‘delta’ in their file names. Deltas indicate snapshot files.
find –iname “*-delta.vmdk”
Or, to find orphaned snapshots that have not been modified in a number of days, type:
find –iname “*-delta.vmdk” –mtime +7 ls
The second method requires one of the free Perl scripts (SnapHunter or SnapAlert) that were written by VMware users. This method requires use of a small Perl script which can be run inside the ESX service console or with the remote command-line utility (Remote CLI) and will search for snapshots and create a report. (You have the option to email the report.) To use these scripts you copy it to the service console or the workstation/appliance running the Remote CLI, modify the script with your vCenter or ESX server name and log in credentials, and then run them.
I also listed a third method that used a VB script to query the vCenter Server’s VPX_SNAPSHOT table for active snapshots. While this method works, it will only show snapshots that vCenter Server is aware of and may not show orphaned snapshots or those taken outside of vCenter Server. Also, since the database design is subject to change with any vCenter Server upgrades, this may break any existing SQL queries. So I’d like to recommend a different method instead which involves using PowerShell and the VMware Infrastructure Toolkit to query for snapshots. You can use simple PowerShell commands to check for snapshots. There are a few sample scripts that you can use. You can find them at the following URLS:
Lastly, there are a few more methods that you can take advantage of by using a reporting or search application. Check out the freely available RV Tools or vKernel’s SearchMyVM. Both enable you to search and report on your virtual environment. These free tools are a good addition to any VMware environment. RV Tools is a .NET application that installs on a workstation and SearchMyVM is a virtual appliance that you can download and import to an ESX host.
Whichever method you choose, you should make sure to periodically look at the snapshots running in your environment. You can automate many of these queries (i.e. using a cron job or Windows task scheduler) so that they run on a scheduled basis. By staying on top of your snapshots, you ensure optimal performance of your hosts and VMs and also avoid disk space problems.