PowerShell script exchange
Post Reply
gk87
Influencer
Posts: 15
Liked: never
Joined: Jun 09, 2017 11:47 am
Contact:

Search vbrBackupSession for any warnings or failures

Post by gk87 »

I'd like to search a vbrBackupSession for any warnings or failures in case the last vbrBackupSession is failed and the currently "idle" one is finished but "Waiting for the new copy interval" which can take hours / days.
This is to prevent false positives in our monitoring tool. Any ideas on how to get this data?

Example data:
Name: Backup Copy Job 1
State: Stopped
Result: Failed

CreationTime: 13-7-2017 00:00:32

Name: Backup Copy Job 1
State: Idle
Result: None

CreationTime: 13-7-2017 00:36:59
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Search vbrBackupSession for any warnings or failures

Post by veremin »

Assuming I got it right, you need to do the following:

1) Backup copy jobs that satisfy two conditions (Latest State = Idle, Latest Result = None)
2) For those satisfying the conditions, get second to last sessions
3) Check state of those sessions

Feel free to check this subforum, there are several examples doing similar stuff.

Thanks.
gk87
Influencer
Posts: 15
Liked: never
Joined: Jun 09, 2017 11:47 am
Contact:

Re: Search vbrBackupSession for any warnings or failures

Post by gk87 »

Let me clarify my request with a screenshot. The below session has state Idle and status None but it does contain errors. How can I check that idle ("Waiting for the new copy interval") session for those errors/warnings?

Image
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Search vbrBackupSession for any warnings or failures

Post by veremin »

Ahh, in this case you will need to check log of the latest job session, finding "Error" entities. Something like this:

Code: Select all

$Session = (Get-VBRJob -name "Name ").FindLastSession()
$Log = $Session.Logger.GetLog().updatedrecords | where {$_.status -eq "Efailed"} | select Title
Thanks.
gk87
Influencer
Posts: 15
Liked: never
Joined: Jun 09, 2017 11:47 am
Contact:

Re: Search vbrBackupSession for any warnings or failures

Post by gk87 »

That's great, thank you Vladimir :-)
gk87
Influencer
Posts: 15
Liked: never
Joined: Jun 09, 2017 11:47 am
Contact:

Re: Search vbrBackupSession for any warnings or failures

Post by gk87 »

You wouldn't happen to know how I can check for the number of total running sessions right? (including all type of jobs: Endpoint backups, surebackups, SQLlogBackups, replications, etc.)

I was thinking of doing the following but it looks a bit rough and I was wondering if I have everything covered with this:

Code: Select all

$jobs = @()
$jobs += Get-VBREPJob | Where {$_.LastState -ne "Stopped"} # Get status of VBREP jobs
$jobs += Get-VSBJob | Where {$_.GetLastState() -ne "Stopped"} # Get status of VSB jobs
$jobs += Get-VBRJob| Where {$_.GetLastState() -ne "Stopped" -and $_.GetLastState() -ne "Idle"} # Get status of VBR jobs
$jobs +=  Foreach ($vbrJob in (Get-VBRJob) | where {$_.FindChildSqlLogBackupJob()}) {$vbrJob.FindChildSqlLogBackupJob() | Where {$_.GetLastState() -ne "Stopped"}} # Get status of SQL jobs

($jobs | measure).count # How many jobs are working?
$jobs | select name, @{Name="LatestRun"; Expression = {$_.ScheduleOptions.LatestRunLocal}}, @{Name="LatestState"; Expression = {$_.GetLastState()}} # Give back information
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Search vbrBackupSession for any warnings or failures

Post by veremin »

Seems more or less OK. Don't forget about SQL jobs and tape ones (if you have any):

Code: Select all

Get-VBRTapeJob | where {$_.LastState -ne "Stopped"}
Thanks.
gk87
Influencer
Posts: 15
Liked: never
Joined: Jun 09, 2017 11:47 am
Contact:

Re: Search vbrBackupSession for any warnings or failures

Post by gk87 »

I couldn't find anything on the following:

Some sessions are sometimes reported as warning. The session's warning is "Processing finished with warnings at 3/2/2017 1:18:02 AM" which doesn't say much.
The specific warning is located under the warning status of one or more VM's: "Changed block tracking cannot be enabled: one or more snapshots present.".

Is it somehow possible to exclude specific warnings and report the session as Success if no other kind of warnings are present using Powershell?
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Search vbrBackupSession for any warnings or failures

Post by veremin »

VM specific issues are reported in task session log (Get-VBRTaskSession).

So, you will need to:

- Check task session log first
- See whether there are any warnings
- If either there are no warnings or the only warning reported there is the one about snapshot presence, mark such job as successful

Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests