PowerShell script exchange
Post Reply
mrholm
Expert
Posts: 170
Liked: 15 times
Joined: Apr 20, 2018 8:12 am
Full Name: Mats Holm
Contact:

script to report on failure in backup copy jobs

Post by mrholm »

Hi
I'd like to have a powershell script that can report on failures in backup copy jobs directly when they appear in the job. As it is now we only get failure/error on a backup copy job after the interval is stopped. We like to be able to see failures in jobs even when the interval is running so we can take action on it ASAP.
We're integrating Veeam into SCOM but the MP from Veeam only report on failures after the copy job is failed.

Anyone else have this script or any ideas on how to handle it?

//Mats
wishr
Veteran
Posts: 3077
Liked: 453 times
Joined: Aug 07, 2018 3:11 pm
Full Name: Fedor Maslov
Contact:

Re: script to report on failure in backup copy jobs

Post by wishr »

Hi Mats,

MP guy here.

Basically, MP copy job monitoring works based on B&R events. The copy job status events are published only once the interval has ended (otherwise there might be false-positives). Before the end of the current interval B&R shows the status of the previous one. Put simply, MP utilizes the status control logic that B&R offers.

It might be possible to create and use events that appear once a restore point is transferred by the copy job, but this will cause a significant unnecessary load on both B&R and SCOM servers. Keep in mind, that you may have hundreds of copy jobs with dozens of VMs and many B&R servers, so the event generation rate might become a huge issue. In large enterprise-scale environments, where MP usually plays each unnecessary workflow may lead to the inability of the Microsoft SCOM Agent to process the data. It has 75k workflows processing limit. Performance- and scalability-wise the current implementation offers a better experience for our customers.

I'm not sure if it's possible to be done via PS either. @veremin should be able to comment on that in more details.

Thanks
Vek17
Service Provider
Posts: 49
Liked: 15 times
Joined: May 29, 2018 8:42 pm
Contact:

Re: script to report on failure in backup copy jobs

Post by Vek17 » 1 person likes this post

This would be the type of command you would need to run in powershell. I'll leave it to you to set up how you want to run this for monitoring and reporting, but this will find failed tasks (Vms/Agents) within a backup copy without having to wait for the copy interval to end.

Code: Select all

function Find-FailedTasks{
    [CmdletBinding()]
    param(
        [Parameter(Mandatory=$True)]
        [DateTime]$EndTime,
        [Parameter(Mandatory=$True)]
        [Veeam.Backup.Core.CBackupJob] $JobList
    )
    Do{
        foreach($Job in $JobList){
            $FailedTaskSessions = $Job.findLastSession().GetTaskSessionsByStatus([Veeam.Backup.Model.ESessionStatus]::Failed)
            if($FailedTaskSessions){
                foreach($Task in $FailedTaskSessions){
                    #Do something about failed task
                }
            }
        }
        Start-Sleep -Seconds 120
    }While($EndTime -gt [DateTime]::now)
}
Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests