--- tags: - "\U0001F6A9purpose/\U0001F5FA️guide" - "⭐topic/\U0001F4BEsoftware/veeam" - ⭐topic/⌗shell/powershell - "⭐topic/\U0001F4BEsoftware/vmware" --- # Remove bugged Veeam snapshots in VMware When a Veeam backup or replication job for a VMware VM starts, it creates a VM snapshot. This snapshot can stick around if vCenter is unreachable when Veeam attempts to remove the snapshot; Veeam may also not attempt to remove the snapshot at all in some failure states. VM snapshots are costly to disk reads since every read must traverse through each snapshot to find the most up-to-date block. Creating new snapshots also takes longer with a build up of older snapshots. Therefore, it is best to minimize VM snapshots in production. One interesting issue occurs if vCenter has multiple of these snapshots. Eventually it will reach a point where creating a new snapshot takes 20 seconds or longer with only a handful of snapshots. This can take long enough that Veeam times out in its backup attempt, which causes the snapshot to not be removed, and the problem to exacerbate. To clean up these temporary snapshots, make sure all Veeam jobs are stopped and collect all the snapshots: ```powershell # NOTE: avoid querying replicas; in the environment I wrote this for, all # replicas ended with _replica. update to suit your environment. $s = Get-VM | Where-Object {-not $_.Name.EndsWith('_replica')} | Get-Snapshot | Where-Object {$_.Name -eq 'VEEAM BACKUP TEMPORARY SNAPSHOT'} | Sort-Object Created -Descending $s | Select-Object VM, Name, Created ``` If the list looks OK (no snapshots within the last ~hour which is probably an active Veeam job) then remove the snapshots: ```powershell $s | Group-Object -Property VM | ForEach-Object {$_.Group | Select -First 1} | Remove-Snapshot -RemoveChildren ``` Removing a snapshot used by an active job will surely cause it to fail. So, don’t do that.