May 25, 2019

PowerShell :: checking VEEAM backups for Nagios

PowerShell ISE logo
(Last Updated On: 16th September 2016)

This little script will check all the configured VEEAM backup jobs (not backup copy jobs) for any that have a last state as FAILED.  It will not check for any jobs that have a last sate of WARNING as these occur too often to make the check useful.

If one backup job has failed, it will return a WARNING to Nagios.

If more than one backup job has failed, it will return a CRITICAL to Nagios.

This script does not check if something has gone wrong and all backups have stopped running in the first place.  To address this I have another script that will look for the last backup to run and if it’s more than 12 hours ago then to flag it.  If this is useful for your environment, find it here.

If you need help configuring this with NsClient, see this guide.

function ReturnAndExit()
param([string]$Jobs = "None",[int]$ExitCode = 0)
if ($Jobs -eq "None") ## If no jobs, assume everything is ok!
echo "No Jobs have failed"
echo "Backup job failed :: $Jobs"

Add-PSSnapin VeeamPSSnapIn

$JobsFailed = Get-VBRJob | Where-Object {$_.GetLastResult() -eq "Failed"}

if ($JobsFailed -is [System.Array])
$Jobs = ""
$JobsFailed | foreach {$Jobs += $_.Name + " :: "} ### Add each job name from the array onto the $Jobs string with some padding between
$Jobs = $Jobs.TrimEnd(" :: ") #### Remove the last padding that gets added
ReturnAndExit $Jobs 2
elseif ($JobsFailed)
ReturnAndExit $JobsFailed.Name 1

Previous «
Next »

Simon is a sysadmin for a global financial organisation and specialises in Windows, security and automation.

1 Comment

  1. Pingback: PowerShell :: checking VEEAM backups are running for Nagios – Synack

Leave a Reply

Subscribe to SYNACK via Email

%d bloggers like this: