Monday, November 22, 2010

Removing left-over snapshots

We recently started using Avamar to perform VMDK backups of our VMware environment. This process creates a snapshot of a VM, mounts the snapshot to a backup appliance, backs up the snapshot, and then deletes the snapshot - a fairly decent process.
Unfortunatly, some times it doesnt delete the snapshot, and if you leave them they can cause issues. The snapshots usually have unique names like 'Avamar-12903912904b5c2b7dc3ea83ca7de0f1c7020f6820cd1f5326', not very descriptive, but at least we know they are Avamar snaps.

Powershell to list the snapshots
$snaps = Get-VM | Sort Name | Get-Snapshot | Where { $_.Name -like 'Avamar*' } 
$snaps | Select VM,Name,Description,Created

Powershell to remove the snapshots
foreach($snap in $snaps) 
{
    Remove-Snapshot -snapshot $snap -confirm:$false
}

1 comment:

edgoad said...

Update -- It appears that sometimes the Avamar snapshot will cleanup, but in the process leave behind a "Consolidate Helper" snapshot.
Including this snapshot name is easy by using an OR clause in the WHERE statement. An updated command is below

$snaps = Get-VM | Sort Name | Get-Snapshot | Where { $_.Name -like 'Avamar*' -or $_.Name -like 'Consolidate Helper*'}
$snaps | Select VM,Name,Description,Created