May 19, 2012

Removing VM snapshots left by CommVault or NetApp

Since I tend to focus on CommVault and NetApp this post is mentioning those two products in particular, but if you’ve used any VM level backup product that quiesces the VM prior to taking the backup – you have likely seen that these VMware snapshots aren’t always removed by the application.  I’ve seen a few different ways to handle this, but since I am a beginner at PowerShell I thought I’d see how I could remove them without using the vSphere Client.

This all started due to a power outage over the weekend in the middle of a VMware backup so I was left with a number of VM’s with the all too familiar ___GX_BACKUP___ snapshot name which I determined by running the following command:

Get-VM | Get-Snapshot | Select Name,VM,SizeMB

Output from PowerCLI showing the existing VM snapshots

This part didn’t tell me anything that I didn’t already know, I have a number of VM snapshots that are left behind from CommVault all with the same snapshot name.  In this particular case I had a backup job that failed, so it had already created the snapshots but hadn’t done the backup which also meant it hadn’t yet come through and removed the VM snapshots.  Next up was running the following command to delete all of those snapshots:

Get-Vm | Get-Snapshot -Name __GX_BACKUP__ | Remove-Snapshot -Confirm:$false

Snapshots being committed

This should kick off a Remove Snapshot job if you have the vSphere Client open.  Let it run and you should have all of your VM snapshots initiated by CommVault committed to disk.

If you are using NetApp SnapManager for VI to backup your virtual machines, your snapshot name will be different.  Instead of ___GX_BACKUP___ it will be something along the lines of smvi_<string of numbers>.  To remove those snapshots you can run the following:

Get-Vm | Get-Snapshot -Name smvi_* | Remove-Snapshot -Confirm:$false

Keep in mind that will delete ALL snapshots that start with smvi_, if you have valid snapshots you’d like to keep that were taken by SMVI, that command isn’t for you.  That should be it, this is pretty basic but I seem to always have to deal with leftover snapshots so I wanted to document this for easy reference.

Popularity: 10% [?]