Delete Veeam ghost backup snapshots with PowerCLI

/, Partners, Virtualization/Delete Veeam ghost backup snapshots with PowerCLI

Delete Veeam ghost backup snapshots with PowerCLI

Sometimes when a Veeam Backup doesn’t finish properly the snapshot that was created by Veeam is not deleted. There is a lot of reasons for a Backup does not end properly and the snapshot not removed. Most of them is a timeout between Veeam Backup Server and the vCenter/Storage. In this blog post, we will delete Veeam ghost backup snapshots with PowerCLI.

A virtual disk stuck in a Veeam Proxy can also trigger this. In this blog post Removing Veeam ghost snapshots, I have explained how to release any Virtual Disk that is stuck in a Veeam Proxy. In this blog post, we will delete with PowerCLI.

If backup administrators do not track this, you could get VMs with dozens of snapshots from Veeam. Veeam will not able to delete the previous one (from the day before), create another backup snapshot and then is not possible to delete again.

I have seen VMs with more than 60 snapshots, because of Veeam Backup Snapshots and then is very difficult to consolidate the disks and fix it.

Note: If you have a VM with dozes of Veeam Backups Snapshots don’t use this script, use the above previous blog post and removed manually.

The next script we can use to search for any Veeam Backup snapshots (using argument VEEAM BACKUP*) with the creating date (we usually should set to -1, will search snapshots created from the previous day), but we can also use to find any snapshot existing in the vCenter or Cluster. Using all search, we can search for snapshots for example, that have more than a week (-7 days).

For safe side, the script will only list the Snapshots will not delete them automatically. To list and delete the snapshot you need to uncomment the delete section.

PowerCLI Script:

Search options:

By name vs date:

The above script was created to find Veeam Snapshots and delete them, but like is in the comments inside the script, it can also be used to find all snapshots existing in the vCenter or a specific Cluster. We just need to comment the line: “If ($Snapshot.Name -like “VEEAM BACKUP*” -and $Snapshot.Created -lt (Get-Date).AddDays(-1))” and then uncomment the line: “If ($Snapshot.Created -lt (Get-Date).AddDays(-7))” to search for all snapshots that have the creating date 7 days behind (will list all snapshots at least one week old).

If you want to search older snapshots (like 30 days old), change the setting to (-30). This setting will list all snapshots older than 30 days. Any snapshot that was created in the last 30 days will not be listed or deleted.

All VMs vs one Cluster:

By default, the script will search for all VMs, regardless if exists one, or more vCenter Clusters. If needed to search in a particular cluster then comment the line: “$VMs = Get-VM” and uncomment the line: “$VMs = Get-Cluster “vCenter Cluster” | Get-VM” and add the Cluster name.

By default the above script and options, only list the VMs and the snapshots information, the script does not delete the snapshots. Check the next section to enable delete the option.

Delete snapshots:

For safe side, deletion of the snapshots is disabled (commented). After you check the list of VMs that have the snapshots and you are sure that you want to delete them, uncomment all bellow section ### Option to delete the Snapshots (do not uncomment this line, only the next lines).

Note: Please be patience when the script is deleting snapshots, this can take some time (monitor the snapshot deletion in the vCenter).

Note: Share this article, if you think it is worth sharing.

©2018 ProVirtualzone. All Rights Reserved
By | 2018-11-26T18:23:24+01:00 November 26th, 2018|Backups, Partners, Virtualization|0 Comments

About the Author:

I am over 20 years’ experience in the IT industry. Working with Virtualization for more than 10 years (mainly VMware). I am an MCP, VCP6.5-DCV, VMware vSAN Specialist, Veeam Vanguard 2018, vExpert vSAN 2018 and vExpert for the last 3 years. Specialties are Virtualization, Storage, and Virtual Backups. I am working for Elits a Swedish consulting company and allocated to a Swedish multinational networking and telecommunications company as a Teach Lead and acting as a Senior ICT Infrastructure Engineer. I am a blogger and owner of the blog

Leave a Reply

%d bloggers like this: