-
- Influencer
- Posts: 16
- Liked: 3 times
- Joined: Apr 25, 2024 8:13 am
- Full Name: can bilgiç
- Contact:
Job session error handling
Hi,
I'm working on a Veeam powershell script, the script pulls the last backup job session information, where it examines the success or failure of the job and I encountered the following problem: if the script fails, is there any way I can pull from powershell at which stage it failed, for example, the reason for the job session failure was an error encountered in the pre script or post script?
Thank you.
I'm working on a Veeam powershell script, the script pulls the last backup job session information, where it examines the success or failure of the job and I encountered the following problem: if the script fails, is there any way I can pull from powershell at which stage it failed, for example, the reason for the job session failure was an error encountered in the pre script or post script?
Thank you.
-
- Veeam Software
- Posts: 2836
- Liked: 647 times
- Joined: Jun 28, 2016 12:12 pm
- Contact:
Re: Job session error handling
Hi can,
Maybe can you share an example of your script? I think I get what you're asking, but it's a little unclear.
I understood that there is just a script running outside of your jobs, but you mention pre/post job scripts, so it's not clear for me if you have a script running after each job checking or if the pre/post scripts were an _example_ of something you want to report on if a job has Warning/Failure.
If you could share your script and clarify the goal, we'd be happy to help.
Maybe can you share an example of your script? I think I get what you're asking, but it's a little unclear.
I understood that there is just a script running outside of your jobs, but you mention pre/post job scripts, so it's not clear for me if you have a script running after each job checking or if the pre/post scripts were an _example_ of something you want to report on if a job has Warning/Failure.
If you could share your script and clarify the goal, we'd be happy to help.
David Domask | Product Management: Principal Analyst
-
- Influencer
- Posts: 16
- Liked: 3 times
- Joined: Apr 25, 2024 8:13 am
- Full Name: can bilgiç
- Contact:
Re: Job session error handling
Hello David ,
With the Get-VBRComputerBackupJobSession function, I pull all the sessions that existed before, from the information I pull from this information, I observe the status of the job from the result and states information, that is, whether it is a failure, succes or warning, the information I am trying to get here is that if a session has failed, is there a method where I can get the reason for failure through the script, for example, something went wrong in the pre-script and the script ended unsuccessfully, as a result of this failed operation in the pre-script, I interrupt the backupjob and the job ends without taking backup. can I access this detail (example: job failed because pre-script exit 1)
Thanks.
With the Get-VBRComputerBackupJobSession function, I pull all the sessions that existed before, from the information I pull from this information, I observe the status of the job from the result and states information, that is, whether it is a failure, succes or warning, the information I am trying to get here is that if a session has failed, is there a method where I can get the reason for failure through the script, for example, something went wrong in the pre-script and the script ended unsuccessfully, as a result of this failed operation in the pre-script, I interrupt the backupjob and the job ends without taking backup. can I access this detail (example: job failed because pre-script exit 1)
Thanks.
-
- Veeam Software
- Posts: 2836
- Liked: 647 times
- Joined: Jun 28, 2016 12:12 pm
- Contact:
Re: Job session error handling
Got it, now it's more clear.
The actual failure of pre/post job scripts and pre-freeze/post-thaw scripts is very limited. When Veeam sends a script to be executed by the OS, we only get the exit code and the top level error (sometimes), because that's all that's returned to us. Unfortunately there's not a way for the script to give feedback to Veeam about why it failed beyond the exit code. I suppose you could set custom exit codes in your scripts, those should be returned, and you should see it in the results from Get-VBRTaskSession. Pass a CBackupSession object to Get-VBRTaskSession -Session, and you should see the message on script failures and the exit code.
But there's not a means of getting the full script failure details from pre/post job scripts and prefreeze/postthaw scripts.
The actual failure of pre/post job scripts and pre-freeze/post-thaw scripts is very limited. When Veeam sends a script to be executed by the OS, we only get the exit code and the top level error (sometimes), because that's all that's returned to us. Unfortunately there's not a way for the script to give feedback to Veeam about why it failed beyond the exit code. I suppose you could set custom exit codes in your scripts, those should be returned, and you should see it in the results from Get-VBRTaskSession. Pass a CBackupSession object to Get-VBRTaskSession -Session, and you should see the message on script failures and the exit code.
But there's not a means of getting the full script failure details from pre/post job scripts and prefreeze/postthaw scripts.
David Domask | Product Management: Principal Analyst
-
- Influencer
- Posts: 16
- Liked: 3 times
- Joined: Apr 25, 2024 8:13 am
- Full Name: can bilgiç
- Contact:
Re: Job session error handling
Hello, David,
Unfortunately, “Get-VBRBackupSession” and “Get-VBRTaskSession” don't seem to be a solution for my case, As I mentioned before, I use the “Get-VBRComputerBackupJobSession” method in my code and “Get-VBRTaskSession” accepts only the “Get-VBRBackupSession” object as a parameter and this doesn't seem to be compatible with my workflow. Do you have a solution you can suggest based on this?
Unfortunately, “Get-VBRBackupSession” and “Get-VBRTaskSession” don't seem to be a solution for my case, As I mentioned before, I use the “Get-VBRComputerBackupJobSession” method in my code and “Get-VBRTaskSession” accepts only the “Get-VBRBackupSession” object as a parameter and this doesn't seem to be compatible with my workflow. Do you have a solution you can suggest based on this?
-
- Veeam Software
- Posts: 2836
- Liked: 647 times
- Joined: Jun 28, 2016 12:12 pm
- Contact:
Re: Job session error handling
Hi can,
You actually can pass the results of Get-VBRComputerBackupJobSession straight to Get-VBRTaskSession on the -Session parameter:
The User Guide doesn't reflect this correctly and tells it must be a CBackupSession object, but it's not correct. I will ask the User Guide be updated.
You actually can pass the results of Get-VBRComputerBackupJobSession straight to Get-VBRTaskSession on the -Session parameter:
Code: Select all
PS C:\Users\david.LAB> $sess = Get-VBRComputerBackupJobSession | select -First 1
PS C:\Users\david.LAB> Get-VBRTaskSession -Session $sess
Name Status Operation
---- ------ ---------
hk-solaris03 Success
PS C:\Users\david.LAB> $sess.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False VBRSession Veeam.Backup.PowerShell.Infos.VBRUniqueObject
David Domask | Product Management: Principal Analyst
-
- Influencer
- Posts: 16
- Liked: 3 times
- Joined: Apr 25, 2024 8:13 am
- Full Name: can bilgiç
- Contact:
Re: Job session error handling
Hi david,
I was able to use Get-VBRTaskSession it thank you for your help.
I was able to use Get-VBRTaskSession it thank you for your help.
Who is online
Users browsing this forum: No registered users and 2 guests