Backup Software

Check for Orphaned Veeam Temporary Snapshots

For those using Veeam Backup & Replication in a vSphere environment perhaps backing up hundreds of virtual machines one of the important housekeeping items you may want to keep a check on is any Veeam temporary snapshots that may for whatever reason been left over from a backup run. I have seen cases where temporary snapshots get leftover for any number of reasons but typically there is a reason why the temporary snapshot doesn’t get deleted. This can cause issues down the road as any snapshot left running in production can deteriorate performance, and cause issues. It can also cause issues with future Veeam backups on a particular virtual machine. Thankfully, using PowerShell, we can quickly find a Veeam snapshot that might be leftover from a run that did not cleanly finish. Let’s look at how to check for orphaned Veeam temporary snapshots with PowerShell PowerCLI.

What causes the orphaned Veeam Temporary Snapshots?

When Veeam Backup & Replication starts the backup or replication job, it creates the “VEEAM BACKUP TEMPORARY SNAPSHOT”. According to an official Veeam KB article found here, In some cases the API command to remove the temporary snapshot is not received or not executed. This can be due to network connectivity issues between the Veeam Backup & Replication server and the vCenter Server or between vCenter and the ESXi host itself.  Whatever the case, there is some interruption in the chain of commands that get communicated that prevents the temporary snapshot from getting deleted.

As shown below, the temporary snapshot size can be quite large on large disk layout virtual machines.

Veeam-Temporary-Snapshot-on-a-virtual-machine
Veeam Temporary Snapshot on a virtual machine

Check for Orphaned Veeam Temporary Snapshots

Make sure you are running the latest version of PowerCLI.  In case you haven’t heard, there is a new way to install PowerCLI.  Once you have PowerCLI loaded and current with the latest version, you should be good to go.  The script is fairly simple and is just a modified version of checking for any snapshots with PowerCLI.  You can set the “OlderThan” variable with the number of days that you want to count back.  Any Veeam temporary snapshots should not hang around very long as these are created and deleted with each backup run.  So, if you check for any Veeam Temporary snapshots that are older than a day even, you should be able to catch any that may have not been properly deleted.

The script currently just outputs to a txt file but the output can be formatted and customized as needed.  With the output file, the script also has a section included that will email an attachment which is more helpful if you are scheduling it via a scheduled task, however, you can customize it as needed.

#Connect vCenter

If ($Cred -eq $null)
{
$cred = get-credential
}
If ($vcenter -eq $null){
$vcenter = Read-Host  -Prompt 'Enter vCenter Server Name'
}
$vi = connect-viserver $vcenter -credential $cred

$CurrentDate = Get-Date
$OlderThan = -1
$CheckSnapshotDate = $CurrentDate.AddDays($OlderThan)


$VeeamSnapsOld = Get-VM | Get-Snapshot | Where {$_.Created -lt $CheckSnapshotDate -and $_.Name -like "VEEAM BACKUP TEMPORARY SNAPSHOT"} | Select-Object VM, Name, Created, SizeGB | sort-object SizeGB -descending

$VeeamSnapsOld | out-file <file path.txt>

if ($VeeamSnapsOld -ne $null) {

send-mailmessage -from "<from email address>" -to "<to email address>" -subject "Veeam Snapshots" -body "There are old Veeam Snapshots detected" -smtpserver <SMTP server> -attachments <attach outfile>

}

disconnect-viserver -confirm:$false

Thoughts on how to Check for Orphaned Veeam Temporary Snapshots

Keeping a check on snapshots in general in a vSphere environment is something that as vSphere virtualization administrators we do on a daily basis or at least fairly often.  If you are like me, having an automated mechanism to proactively discover and be alerted of existing snapshots is a much better way of handling discovering snapshot issues in an environment.  Most of today’s modern data protection solutions utilize temporary snapshots to be able to copy data while the virtual machine is running.  Keeping a check on these temporary snapshots ensures things will continue running smoothly.  In the case of Veeam, it is always a good idea to check for orphaned Veeam temporary snapshots and using PowerCLI takes the heavy lifting out of the process.

Subscribe to VirtualizationHowto via Email 🔔

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Brandon Lee

Brandon Lee is the Senior Writer, Engineer and owner at Virtualizationhowto.com and has over two decades of experience in Information Technology. Having worked for numerous Fortune 500 companies as well as in various industries, Brandon has extensive experience in various IT segments and is a strong advocate for open source technologies. Brandon holds many industry certifications, loves the outdoors and spending time with family.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.