We have multiple ESXi servers managed by a vCenter; is there a way to get a list of all the snapshots in all the VMs?
-
2Some good answers below. Get yourself a copy of [RVTools](http://www.robware.net/) as well if you're supporting vCenter. – jscott Nov 13 '14 at 16:46
11 Answers
Grrr... VMware snapshots. If I had my way, they'd only exist for backup purposes and for testing changes.
You can view the space consumed by snapshots (which is probably what you're really interested in knowing) by using the "Storage Views" tab at the cluster level in your vSphere client.
Start there, then drill down to the individual VMs. The entries that have values in Bytes (B) essentially mean that there are no snapshots.
- 194,921
- 91
- 434
- 799
-
This has been removed from vSphere Client: https://kb.vmware.com/s/article/2112085 – CitizenRon Oct 01 '18 at 17:24
-
1
Sounds like a job for PowerCLI! Well, from a Windows workstation, anyway, which is what I have.
The Surly Admin's blog even has a script that you can copy-pasta to get all the snapshots for all the VMs in your environment, the meat of which I'll post below for your convenience.
$Report = Get-VM | Get-Snapshot | Select VM,Name,Description,@{Label="Size";Expression={"{0:N2} GB" -f ($_.SizeGB)}},Created
If (-not $Report)
{ $Report = New-Object PSObject -Property @{
VM = "No snapshots found on any VM's controlled by $VIServer"
Name = ""
Description = ""
Size = ""
Created = ""
}
}
$Report = $Report | Select VM,Name,Description,Size,Created | ConvertTo-Html -Head $Header -PreContent "<p><h2>Snapshot Report - $VIServer</h2></p><br>" | Set-AlternatingRows -CSSEvenClass even -CSSOddClass odd
- 53,385
- 32
- 133
- 208
-
1This is a great answer. I've gotten a lot of good use out of PowerCLI, but if Powershell isn't your thing, PowerCLI (and this answer in particular) is a great example of a vSphere API Client, so feel free to check out the vSphere API docs for your language of choice! – gWaldo Nov 13 '14 at 20:50
HopelessNoob's answer is great for a human readable report. Sometimes I prefer to parse mine into other PS objects. It is very similar too HopelessNoob's - I guess we both started from the same code snippet to build our scripts:
$VIServer = "vsphere.ad.example.com"
If (-not (Get-PSSnapin VMware.VimAutomation.Core))
{ Try { Add-PSSnapin VMware.VimAutomation.Core -ErrorAction Stop }
Catch { Write-Host "Unable to load PowerCLI, is it installed?" -ForegroundColor Red; Break }
}
Connect-VIServer $VIServer -Credential (Get-Credential) | Out-Null
Get-VM | Get-Snapshot | Select VM,Name,Description,@{Label="Size";Expression={"{0:N2} GB" -f ($_.SizeGB)}},Created | FT
Gives:
VM Name Description Size Created
-- ---- ----------- ---- -------
ENETSXS2 VEEAM BACKUP TEMPORARY SNAPSHOT Please do not delete this sn... 19.28 GB 8/11/2014 8:42:18 AM
ENETSDFS-BS VEEAM BACKUP TEMPORARY SNAPSHOT Please do not delete this sn... 16.30 GB 8/11/2014 5:24:44 AM
You can then pipe that into Remove-Snapshot
or filter it or whatever.
- 68,316
- 31
- 175
- 255
Here is the script that we use to dump a list of all of the VM's with snapshots, works in PowerCLI. It is very simple and clean. It will dump the results to your local desktop via a .csv file.
# Possible "Select-Object -Property" variables: Description, Created, Quiesced, PowerState, VM, VMId, Parent, ParentSnapshotId, ParentSnapshot, Children, SizeMB, SizeGB, IsCurrent, IsReplaySupported, ExtensionData, Id, Name, Uid, Client
get-vm | get-snapshot | Select-Object -Property vm,created,sizeGB,name,description | Export-Csv -Path C:\Users\$env:username\Desktop\snapshots.csv
- 51
- 1
- 1
This worked for me in vSphere 6.7 (Web Client):
- Go to storage, and click the datastore
- Click the files tab
- Type "snap" in the file search box
- It will list the snapshot files, and you can determine the VMs based on the snapshot file name.
- 31
- 2
Even if an answer has been accepted, I'd like to point you to check_vmware_snapshots.
It's a Nagios / Icinga plugin, to check the age and count for VM snapshots in a VMWare ESXi/vSphere environment.
It depends on Perl / VMware::VIRuntime from "VMware-vSphere-CLI-5.5.0", so no PowerCLI or -shell this time. :-)
- 1,321
- 11
- 24
Unfortunately the thick client for Vcenter hasn't had this feature ever since 6.0 I believe but here's another option if you want to do it easily in a GUI. In 6.0 or 6.5 launch the vcenter web client (flash version). On the left side (navigator window) select either vcenter, a data center, or a cluster then select to view VMs. On the right hand side to the left of the "filter" box there's a small square icon (hovering over it says "Show and hide quick filters". click that square icon, then click "has snapshot" then click "yes". Your view will now display only VMs with snapshots. Enjoy!
- 11
- 1
Simple native method to do that is just use the following one liner on the targeted ESXi host after you SSH to it and it will show you the VM id and it's snapshot detail beneath:
SSH to the ESXi and run this:
for i in $(seq 1 60); do echo 'VM Id:' $i && vim-cmd vmsvc/get.snapshotinfo $i; done
Once you get the result VM id from the above command, run the below command to get all the VM IDs and details to get the exact name of the VM.
vim-cmd vmsvc/getallvms
Good luck!
In vSphere Client, you can at least find out where a Snapshot hides. "needs consolidation" is the hint. To get there: List your VMs. In the headline of the list, click Show/Hide Columns (small dropdown arrow in each columns end). Select "needs consolidation". If there is no snapshot, consolidation is "not required".
- 1
-
Sadly this is not always the case. Sometimes VMs still need consolidation when Snapshots have already been deleted. – Gerald Schneider Jul 01 '22 at 16:05
Open vCenter with vSphere Client. Navigate to
"Datastore and Datastore Cluster" Category
"R-Click on Datastore" where you want to find Snapshot. (If multiple Datastore then have to go in each Datastore)
You will See Folder and Search Tab.
Click to See Image of Search Tab
Click on Search, Then from Drop Down select "Virtual Machine Snapshot"
Click Search.
It will show all the Snapshot stored in that datastore.
R-Click on Snapshot and "Go to Folder"
It will take to VM Folder of which Snapshot is taken.