PowerShell script exchange
Post Reply
aantonacci@shci.ca
Influencer
Posts: 21
Liked: never
Joined: Oct 19, 2020 7:42 pm
Full Name: Anthony Antonacci
Contact:

Get Full Warning from a BackupSession Task

Post by aantonacci@shci.ca »

hi Guys,

For a particular backup, in the GUI, I have 3 warnings in the log.

When I retrieve the information from the PowerShell command, I only have the first "reason" - and with this reason its not clear what went on. How do I get all the warning messages from a backup session task?

Ex: (From Gui) - 3 logs with the "warning" symbol next to it - the powershell only shows me the first one?

2022-04-05 5:04:48 PM :: Retrying snapshot creation attempt (Could not create backup checkpoint for virtual machine ' ABC Windows 2016 Standard': The shadow copy provider had an unexpected error while trying to process the specified operation. (0x8004230F). (Virtual machine ID EB0E7031-71F4-4D3B-92C3-4B261E71632D))
2022-04-05 5:04:48 PM :: Task has been rescheduled
2022-04-05 5:15:23 PM :: Processing finished with warnings at 2022-04-05 5:15:23 PM


When I pull the warning message from PowerShell I only get the first message...

$sessions | sort-Object CreationTimeUTC | select-object -last 10
$sessions | select-object name,jobname,creationtime,id # find the session i want
$session = $sessions | where-object {$_.id -eq "f96980a4-0ad7-4443-a67f-6cfb1bfdb0eb"}
$sessiontasks=Get-VBRTaskSession $session
$sessiontasks.info

results:
Id : f9d078fe-24e3-42e5-baa9-b14782ce2d79
ObjectName : ABC - Windows 2016 Standard
Reason : Retrying snapshot creation attempt (Could not create backup checkpoint for
virtual machine 'BVA-E16 - Windows 2016 Standard': The shadow copy provider had
an unexpected error while trying to process the specified operation.
(0x8004230F). (Virtual machine ID EB0E7031-71F4-4D3B-92C3-4B261E71632D))
QueuedTime : 2022-04-05 5:00:23 PM
SessionId : f96980a4-0ad7-4443-a67f-6cfb1bfdb0eb
WorkDetails : Veeam.Backup.Model.CBackupTaskWorkDetails
ObjectPlatform : EHyperV
Progress : Veeam.Backup.Model.CBackupProgressData
ObjectId : 4c1ea042-7c66-4630-9561-c83d4e9b5761
Status : Warning
Operation :
SourceMode : Unknown
ChangeTracking : True
RetryCounter : 0
FormattedIpAddress :
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Get Full Warning from a BackupSession Task

Post by david.domask »

Hey @aantonacci@shci.ca ,

As far as I know for official cmdlets, only the "top" error/warning is returned.

If you're ready to go into unsupported territory, there is a bit of trickery you can do.

As with all such internal methods, no support is offered and you use at your own risk! It can (and likely) will change in future updates. Veeam Support cannot help with such internal methods (Though this one is pretty harmless ;) So mostly just about maintaining it)

CBackupSession objects have a function called Logger, and it replays what you see in the UI. Get your job and then get the last session (officially with Get-VBRBackupsession, the other session cmdlets, or like I do below), then call the Logger property and use its method GetLog()

Code: Select all

PS C:\Users\Administrator> $job = Get-vbrjob -name 'archive-tier-job'
PS C:\Users\Administrator> $sess = $job.FindLastSession()
PS C:\Users\Administrator> $logs = $sess.Logger.GetLog()
Logger will return something like the following:

Code: Select all

PS C:\Users\Administrator> $logs

RemovedRecords UpdateUSN UpdatedRecords
-------------- --------- --------------
{}                    29 {23, 22, 21, 20...}


PS C:\Users\Administrator> $logs | gm


   TypeName: Veeam.Backup.Common.CTaskLogUpdates

Name                        MemberType Definition
----                        ---------- ----------
Clone                       Method     Veeam.Backup.Common.CTaskLogUpdates Clone(uint64 usnShift)
ConvertForeignTimeToLocal   Method     void ConvertForeignTimeToLocal(timespan timeShift)
Equals                      Method     bool Equals(System.Object obj)
GetAttentionRecords         Method     Veeam.Backup.Common.CTaskLogRecord[] GetAttentionRecords()
GetHashCode                 Method     int GetHashCode()
GetRecordsSortedByOrdinalId Method     Veeam.Backup.Common.CTaskLogRecord[] GetRecordsSortedByOrdinalId()
GetType                     Method     type GetType()
GetUpdates                  Method     System.Collections.Generic.IEnumerable[Veeam.Backup.Common.CTaskLogRecord] Ge...
IsAnyFailedRecords          Method     bool IsAnyFailedRecords()
IsAnyWarningRecords         Method     bool IsAnyWarningRecords()
Serial                      Method     void Serial(System.Xml.XmlNode node)
SerialWithRoot              Method     string SerialWithRoot()
ToString                    Method     string ToString()
RemovedRecords              Property   Veeam.Backup.Common.CTaskLogRemovedRecord[] RemovedRecords {get;}
UpdatedRecords              Property   Veeam.Backup.Common.CTaskLogRecord[] UpdatedRecords {get;set;}
UpdateUSN                   Property   uint64 UpdateUSN {get;set;}
Don't touch the other methods, but you can use GetRecordsSortedByOrdinalID() to get all of the messages printed to console.

I haven't used GetAttentionRecords(), but it looks like it returns warnings and errors only, which I think is what you want. I don't have any jobs in my lab that quite match what you're seeking.

A record has the following output you can parse on:

Code: Select all

PS C:\Users\Administrator> $logs.GetAttentionRecords()


Visibility    : VisibleToAll
Status        : EWarning
OrdinalId     : 3
UpdateUsn     : 4
Title         : ddom-multidisk-tester is no longer processed by this job. Make sure this change is intentional
Description   :
UpdateTime    : 4/7/2022 22:00:30
Style         : ENone
Object        :
StartTime     : 4/7/2022 22:00:30
Cookie        :
VisibilityInt : 0
You might think to filter on Status = EWarning, but unfortunately this might give you some "green" UI items as it will also flag EWarning for some items that are benign but an interruption to the job, for example, "Waiting for Backup Infrastructure availability" (which eventually turns green), so I'd play with GetAttentionRecords() and see if it helps. Alternatively, you can just filter out the non-interesting records based on Title.

Task Sessions have a similar system you can use, so the above should apply, just fetch a TaskSession via the usual cmdlets (or methods).
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests