Bulk VMware Snapshot Management/Removal with PowerCLI

IT

Bulk VMware Snapshot Management/Removal with PowerCLI

//

We utilize Veeam’s Backup & Replication product for local backups as well as offsite DR replication. The software is overall very good, but can have some quirks if things don’t go as planned. One issue we hit is longer-running replica jobs might conflict with local jobs, causing jobs to fail, and snapshots to get locked and abandoned. Also, at times, we run into the Consolidate Helper snapshots when the ESX host is too busy, or hits another issue.
These conditions should get much better with Veeam 6 and vSphere 5, but we even had a new one pop up seemingly at random. 

Failed to retrieve "SCSI (0:1) Hard disk 2" disk information. Check VM virtual hardware configuration. 
Cannot create CSoapPath from ssh path '/vmfs/volumes/guid/machine.vmdk'. Veeam Backup will attempt to remove snapshot during the next job cycle, but you may consider removing snapshot manually. Possible causes for snapshot removal failure: - Network connectivity issue, or vCenter Server is too busy to serve the request - ESX host was unable to process snapshot removal request in a timely manner - Snapshot was already removed by another application

This is caused by a last minute change by VMware with the RTM vSphere 5 release, and Veeam is hurriedly working on an update to address the problem. The backups are working, but Veeam is unable to properly remove them for most of the VMs in the backup jobs.
Working with the vSphere Client is pretty cumbersome and clunky when trying to rapidly check machines for certain states, and in my case, are old-running snapshots. This is where I pull out the vSphere PowerCLI, a free download from VMware.

Fire up the PowerCLI powershell prompt, and start with a simple connection: 

 connect-viserver vCenterServer

Name                           Port  User
----                           ----  ----
vCenterServer                  443   domainuser

Next, use the following command to list out the current snapshots for all machines:

 get-snapshot -vm * | select VM, Name, SizeMB, @{Name=”Age”;Expression={((Get-Date)-$_.Created).Days}}

In my instance, I had several starting that needed to be removed starting with “VEEAM BACKUP”. After ensuring all Veeam B&R jobs were idle, I ran first for verification:

 Get-Snapshot -vm * -name “VEEAM BACKUP*”

Finally, the removal command:

 Get-Snapshot -vm * -name “VEEAM BACKUP*” | remove-snapshot

Confirm
Are you sure you want to perform this action?
Performing operation "Removing snapshot." on Target"VirtualMachineSnapshot-snapshot-3979".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help(default is "Y"):A

At that point you’ll receive the typical PowerShell progress bar to indicate performance, and you’ll see the operations executing in your vSphere Client.
There are plenty of operations that can be performed with the PowerCLI, just figured I’d share one that’s useful and relevant right now.

More About the Author

Daniel Holm

Chief Architect, IT Services
Quick Q&A: Why We Like Dell-EMC for Just About Everything IT In this edition of “Quick Q&A,” we talk about Dell-EMC with InterWorks Director of Enterprise Solutions Daniel Holm, IT ...
Testing the Beta NVIDIA RTX Audio Driver NVIDIA is always pushing the limit of what their video cards can do. However, they have now started to use the AI abilities they ...

See more from this author →

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK

×

Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Germany
Geschäftsführer: Mel Stephenson

Kontaktaufnahme: markus@interworks.eu
Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072

×

Love our blog? You should see our emails. Sign up for our newsletter!