VM snapshots are an extremely useful feature in vSphere but they can also be miss-used and retained for much longer than they should, sometimes weeks, months and even years! Sadly, having a forgotten VM snapshot for a year or longer is not actually as rare as you might expect and I have definitely heard some interesting stories from our field and customers.
While cleaning up a recent VM snapshot, I noticed a new option in the delete all snapshot workflow that now allow users to specify the age of the snapshot to remove which is a new feature in the latest release of vSphere 8.0 Update 3.
This makes it easy for administrators to quickly delete old snapshots without having to write any automation, which is typically how most users manage snapshot retention period including an event-driven approach using the VMware Event Broker Appliance (VEBA) solution.
You can combine this new new capability in vSphere 8.0 Update 3 with the existing vSphere Scheduled Task that can periodically clean up existing snapshots and administrators now have an additional control to quickly specify the age of a snapshot to remove without having to create or rely on a custom script that would need to be scheduled outside of vCenter Server! While this may be a tiny feature, it definitely brings better operation management to administrators so that they can ensure their vSphere environment is running optimally and hopefully never worrying about a VM snapshot persisting for more than their desired policies.
For those interested from an automation perspective, you can also control the number of days by specifying the retentionDays property in the RemoveAllSnapshots_Task() vSphere API method, which can be consumed through PowerCLI or any other vSphere SDK.
Mahendran says
Is this possible to remove with snapshot on the description name based ?
William Lam says
Yes, but it’ll be custom script that’ll do evaluation which would then run on some scheduled (typically OS scheduled)
Ben says
We delete Snapshots older than 3 days with a powershell script. This new feature would be nice. But sadly VMware havent thought about this completely. Should I now create this task for several thousand VMs? Why can't I make this an cluster/vcenter wide task for alle VMs by default? So we have to stick with our script.
Brett says
If you have Aria Operations then you can set it up from within Aria Operations. There is an option called "Automation Central" where you can setup jobs to auto delete powered off vm's after a certain period of time and also to delete snapshots.