PowerShell script exchange
Post Reply
aeccles
Enthusiast
Posts: 82
Liked: 6 times
Joined: May 01, 2012 3:00 pm
Contact:

Result value from Backup Copy Jobs is always none

Post by aeccles »

Whenever I run Get-VBRJob and look at my Backup Copy jobs the result is always "none"
Is there another place I can look to get the results of these jobs? I imagine it must be somewhere since the email alerts contain the information.

Thank you
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Result value from Backup Copy Jobs is always none

Post by veremin »

Have you tried to use .GetLastResult() function?

Code: Select all

asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of your backup copy job"
$Job.GetLastResult()
Thanks.
HvemVet
Novice
Posts: 3
Liked: 1 time
Joined: Mar 23, 2016 9:02 am
Full Name: Ola Danielsen
Contact:

[MERGED]:Result value from Backup Copy Jobs is always none

Post by HvemVet »

How to get the result of a run copy job in powershell? If you use the regular parameter .GetLastResult() that give the correct status for a backup job, you get the answer "none" for a backup copy job,
like described in the thread linked below.
Is there another way to get the information whether last run finished correctly?

The reason for me wanting this information is because its easier to forget to check if the copy jobs are running like they should. :)

The previous a thread for this:
powershell-f26/result-value-from-backup ... 20512.html
PTide
Product Manager
Posts: 6408
Liked: 724 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Result value from Backup Copy Jobs is always none

Post by PTide »

Hi,

Please do not create duplicate topics. I've just checked GetLastResult() and it works fine. What PowerShell and VBR versions are you running? Also please double check if the backup copy job that you've specified in your script did actually run at least once.

Thank you.
HvemVet
Novice
Posts: 3
Liked: 1 time
Joined: Mar 23, 2016 9:02 am
Full Name: Ola Danielsen
Contact:

Re: Result value from Backup Copy Jobs is always none

Post by HvemVet »

Sorry about that. The idea was to make the topic shorter and I forgot that before I submitted it. When I remembered shortly after it was not possible to change it as it was a while impossible to find the post while it was waiting to get published.
Many moderators do like new post in old threads that was why I did not post in that thread.

We are running VBR version 8, and Powershell v.3 (remoting with New-PSSession). Remember that these threads are not about backup jobs (which works fine with GetLastResult() ), but backup copy jobs. Yes, the backup copy job has run many times (with success).
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Result value from Backup Copy Jobs is always none

Post by veremin » 1 person likes this post

If my memory serves me well, only running backup copy job has None as its status, neither disabled nor idling job has the same status.

So, you might want to a simple check to your script. If the job is running, take previous session instead the latest one and check its result.

Code: Select all

asnp VeeamPSSnapin
$BCJ = Get-VBRJob -name "Name of your backup copy job"
if ($BCJ.GetLastResult() -ne "None"){$BCJ.GetLastResult()}
else {(Get-VBRBackupSession -Name $BCJ.name | sort -Descending)[1].Result}
Thanks.
HvemVet
Novice
Posts: 3
Liked: 1 time
Joined: Mar 23, 2016 9:02 am
Full Name: Ola Danielsen
Contact:

Re: Result value from Backup Copy Jobs is always none

Post by HvemVet » 1 person likes this post

Thank you very much! Get-VBRBackupSession solves this. :D

Then it will be:

Code: Select all

Get-VBRBackupSession | Where-Object {$_.OrigJobName -eq "Name of your copy job"}| Select-Object OrigJobName,EndTime,Result
or if you want it displayed nicely:

Code: Select all

Get-VBRBackupSession | Where-Object {$_.OrigJobName -eq "Name of your copy job" -and $_.EndTime -ge (Get-Date).adddays(-7)}| Select-Object OrigJobName,EndTime,Result|ft
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Result value from Backup Copy Jobs is always none

Post by veremin »

You're welcome. If other questions arise, let me know. Thanks.
Aumatics
Novice
Posts: 5
Liked: never
Joined: Oct 14, 2016 11:59 am
Full Name: Aumatics
Contact:

[MERGED] Monitoring script

Post by Aumatics »

Hi,

I am working at a script which i can include in our monitoring tool prtg to check if the backups are having problems.

I come pretty far with get-vbrjobs and getting the "GetLastResult" value, but that does not work for Backup Copy Jobs and Cloud Backups, because they don't have a lastResult as they are continues backups. I am looking for a way to check if the backup copy jobs and Cloud Backups have a warning or error but i cant find it.

Does someone know how we can get this
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Result value from Backup Copy Jobs is always none

Post by veremin »

Check the script provided above; should meet answer requirements. Thanks.
tdewin
Veeam Software
Posts: 1775
Liked: 646 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

[MERGED] Backup Copy Job Newest Result

Post by tdewin »

It seems that if you use "get-vbrbackupsession" to query the last (newest) backup copy job session, the status will be always None (since the job is running in idle state/100% Progress but not done), even if everything is copied successfully. Is there any field/method that can be called to check "successful"-ness, or is the only way to do it by calculating yourself based on the VM result/100% Progress ?

For example (2 last sessions):

Code: Select all

$jobtype = "BackupSync"
#$jobtype = "Backup"
$Jobs = @(Get-VBRJob | ? { $_.JobType -ieq $jobtype }) | Sort-Object -Property Name

$allsessions = Get-VBRBackupSession | ? { $_.jobtype -ieq $jobtype } 
$allorderdedsess = $allsessions | Sort-Object -Property CreationTimeUTC -Descending  

foreach ($Job in $Jobs) {
     $lastsessions = $allorderdedsess | ? { $_.jobname -eq $Job.Name } | select -First 2
     if ($lastsessions -ne $null) {
        $lastsessions | % { 
                  $lastsession = $_;
                  write-host ("Name : {0} Last Result : {1}  Date : {2}" -f $Job.Name,$lastsession.Result,$lastsession.CreationTime) 
         }
     } else {
           write-host ("Could not find Session for {0}" -f $Job.Name)
     }
}  
Result
Name : Endpoint Backup Copy to Cloud Connect Last Result : None Date : 10/23/2016 10:00:36 PM
Name : Endpoint Backup Copy to Cloud Connect Last Result : Success Date : 10/22/2016 10:00:28 PM
Name : Hyper-V - Backup Copy to StoreOnce Last Result : None Date : 10/23/2016 10:04:08 PM
Name : Hyper-V - Backup Copy to StoreOnce Last Result : Failed Date : 10/22/2016 10:06:25 PM
Name : VMware - Backup Copy to Cloud Connect Last Result : None Date : 10/23/2016 10:00:36 PM
Name : VMware - Backup Copy to Cloud Connect Last Result : Success Date : 10/22/2016 10:00:28 PM
Name : VMware - Backup Copy to Cloud Connect with WAN Acceleration Last Result : None Date : 10/23/2016 10:00:09 PM
Name : VMware - Backup Copy to Cloud Connect with WAN Acceleration Last Result : Success Date : 10/22/2016 10:00:28 PM
Name : VMware - Backup Copy to DataDomain Last Result : None Date : 10/23/2016 10:00:09 PM
Name : VMware - Backup Copy to DataDomain Last Result : Success Date : 10/22/2016 10:00:28 PM
Name : VMware - Backup Copy to ExaGrid Last Result : None Date : 10/23/2016 10:00:09 PM
Name : VMware - Backup Copy to ExaGrid Last Result : Success Date : 10/22/2016 10:00:28 PM
Name : VMware - Backup Copy to StoreOnce Last Result : None Date : 10/23/2016 10:00:36 PM
Name : VMware - Backup Copy to StoreOnce Last Result : Success Date : 10/22/2016 10:00:28 PM
PS C:\Windows\system32>
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Result value from Backup Copy Jobs is always none

Post by veremin »

Why not to query a previous session if current one is in idle state? You cannot say anything definitive about session that hasn't finished yet. Thanks.
tdewin
Veeam Software
Posts: 1775
Liked: 646 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: Result value from Backup Copy Jobs is always none

Post by tdewin »

Well the strange thing is, if you push the report (manually/gui/no-powershell) button in the ribbon, it will flag the session as Success. Also strange is that in case it is finished but Idle, the endtime will be different then 1/1/1900 12:00:00 AM

So I guess the only way to mimic this behaviour is:
-check all VMs status (if there is non pending)
-check the details per vm (messages)
-check the job details (messages)
-check if job status is none
-check if endtime is bigger then creationtime
-check if Progress.Percent is 100%
-check if Job is Idle
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Result value from Backup Copy Jobs is always none

Post by veremin »

I still think that it would be easier to either output these sessions in the report as idle ones or to take previous ones instead. However, if it's crucial for you to imitate Report button behaviour, you can stick to the described approach.
grydan
Lurker
Posts: 1
Liked: never
Joined: Aug 28, 2019 9:12 am
Full Name: daniele
Contact:

Re: Result value from Backup Copy Jobs is always none

Post by grydan »

Hello I have tested this script for valid my powershell script also for copy job

Code: Select all

$status = $job.GetLastResult()
if ($status -eq "None") {
 $status = (Get-VBRBackupSession -Name $job.name | sort -Descending)[1].Result
}
but $status in my case returns empty in case of copy job or returns Failed.
In reality the returned state has always been Success...

What am I doing wrong?
I'm using Veema backup & replication 9.5.4.2753
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests