PowerShell script exchange
Post Reply
xasz
Influencer
Posts: 13
Liked: never
Joined: May 21, 2017 8:03 pm
Full Name: Michael Schneider

Veeam V10 SimpleBackupCopyPolicy

Post by xasz »

Hello togehter,

i am using PRTG for Monitoring Veeam quite a while now with a self build powershell script.
Now as Veeam V10 has finally arrived i changed some of my complex BackupCopy Jobs to the new BackupCopy job type with intermediate Setting.
For the side of the backup all works fine, but my Powershell script cannot ready the results of the job and dig a little bit and found, that there are no VBR-Sessions which i could query using Powershell.

A quick very simplified overview:

The Old Setup:
1. Normal Backup Job which backups vm to a local target
1. Backup Copy Job for Offsite Replication scheduled after the Backup Job

The New Setup:
1. Normal Backup Job which backups vm to a local target
1. Backup Copy Job in Intermediate Mode for Offsite Replication

The Powershell

Code: Select all

Connect-VBRServer -Server $VeeamServer -User $VeeamUser -Password $VeeamPassword
$jobs = Get-VBRJob
foreach ($job in $jobs){
        $lastSuccessSession = Get-VBRBackupSession  -WarningAction SilentlyContinue | Where-Object {$_.jobId -eq $job.Id.Guid -and $_.State -eq "Stopped" } | Sort-Object EndTimeUTC -Descending | Select-Object -First 1
        if($lastSuccessSession.Count -gt 0){
            Write-Host "Type: $($job.JobType) Name: $($job.Name) has finished with $($lastSuccessSession[0].Result)"
        }else{
            Write-Host "Type: $($job.JobType) Name: $($job.Name) has no VBRBackupSessions)"
        }
}
Disconnect-VBRServer -WarningAction SilentlyContinue
Output
For sake of simplicty we are assume the jab has already run at least one time

Output with the "Old Setup"

Code: Select all

Type: Backup Name: Backup Local has finished with Success
Type: BackupCopy Name: To Offsite has finished with Success
Output with the "New Setup"

Code: Select all

Type: Backup Name: Backup Local has finished with Success
Type: SimpleBackupCopyPolicy Name: To Offsite has no VBRBackupSessions
Ok so far so good. The new Intermediate mode seems to have an JobType of SimpleBackupCopyPolicy and not BackupCopy.
But as long as i searched the Powershell CMDlets in the Veeam Powershell Help Center i cannot find any way to query them.

I am not sure if this is supposed to happen, that the Get-VBRBackupSession does not return any information about the SimpleBackupCopyPolicy jobs or if there is simply another CMDlet i could't find.

Perhaps anyone has already stumbled over an solution or Veeam could tell us if this is "by Design" or i a missing something here.

Thank you for your time and help.

best regards
Michael
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Veeam V10 SimpleBackupCopyPolicy

Post by oleg.feoktistov »

Hi Michael,

Thank you for noticing it!
Looks like neither Get-VBRBackupSession, nor Get-VBRSession cmdlet are friends with backup copy jobs of SimpleBackupCopyPolicy type.
Raised this question with QA. Will get back to you as soon as we have more information.

Meanwhile, as a workaround, you can trigger .NET static method to retrieve backup copy jobs with immediate mode:

Code: Select all

$job = Get-VBRJob | where {$_.JobType -eq 'SimpleBackupCopyPolicy'}
[Veeam.Backup.Core.CBackupSession]::GetByJob($job.Id)
Best regards,
Oleg
xasz
Influencer
Posts: 13
Liked: never
Joined: May 21, 2017 8:03 pm
Full Name: Michael Schneider

Re: Veeam V10 SimpleBackupCopyPolicy

Post by xasz »

Hello Oleg,

i digged a little deeper and found some strange things with these jobs:

Reports have no History in B&R Console
If i open an report via rightlick on the job, i expect a history of the job. On Jobs with SimpleBackupCopyPolicy there i only always the current run or the last result.

Timestamps are wrong
I tried your workaround and so far it seems to query the Session correct.
But there are just some strange timestamps i don't understand.
I setup a test on a smaller server with only 3 jobs. They have been setup early early this month after upgrade to V10 and run every day from then.
Here is what i query:

Code: Select all

$jobs = Get-VBRJob -WarningAction SilentlyContinue
foreach ($job in $jobs){
    
    if($job.JobType -eq "BackupSync" -or $job.JobType -eq "Backup" -or $job.JobType -eq "SimpleBackupCopyPolicy"){
        
        $lastSuccessSession = $null
        if($job.JobType -eq "SimpleBackupCopyPolicy"){
            $lastSuccessSession = [Veeam.Backup.Core.CBackupSession]::GetByJob($job.Id)
        }else{
            $lastSuccessSession = Get-VBRBackupSession  -WarningAction SilentlyContinue | Where-Object {$_.jobId -eq $job.Id.Guid -and $_.State -eq "Stopped" } | Sort-Object EndTimeUTC -Descending | Select-Object -First 1
        }
        $lastSuccessSession | Select-Object JobType, EndTime, CreationTime, Result
    }
}
Result:

Code: Select all

               JobType EndTime             CreationTime         Result
               ------- -------             ------------         ------
SimpleBackupCopyPolicy 04.03.2020 10:37:40 24.03.2020 19:50:38 Success
SimpleBackupCopyPolicy 01.01.1900 00:00:00 24.03.2020 20:30:20 Success
                Backup 24.03.2020 20:23:40 24.03.2020 19:30:18 Success
The CreationTime is yesterday, but the job definitly exists sind 3 - 4 weeks and the Endtime - Well, i don't understand :)


What my script does is doing with all the other jobs is getting the last Session, check it for result and endtime.
Then i can check the result (obiously) and the last run, because i want to get notified if the job for some reason is stuck, hangs or is disable whatsoever.

Just seems all a little bit strange with these new jobs :)

Edit:
Btw:

Code: Select all

$job.FindLastSession(); 
works as well.
The only reason why i did with

Code: Select all

Get-VBRBackupSession
is that i do not get the last one, i can get the last stopped and not the current runnig, which would have no result like this:

Code: Select all

Get-VBRBackupSession  -WarningAction SilentlyContinue | Where-Object {$_.jobId -eq $job.Id.Guid -and $_.State -eq "Stopped" } | Sort-Object EndTimeUTC -Descending | Select-Object -First 1
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Veeam V10 SimpleBackupCopyPolicy

Post by oleg.feoktistov »

Hi Michael,

Apologies for my belated reply - was on home alone vacation.
If i open an report via rightlick on the job, i expect a history of the job. On Jobs with SimpleBackupCopyPolicy there i only always the current run or the last result.
Thanks, notified QA about that.
The CreationTime is yesterday, but the job definitly exists since 3 - 4 weeks and the Endtime - Well, i don't understand
In your script output CreationTIme corresponds to the last session creation time, not the job creation time. Feels weird with EndTime values though.
Let's see what QA will come up with. We'll let you know as soon as we have any further info, however, I wouldn't expect the answer soon - QA folks have been quite busy.

Best regards,
Oleg
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Veeam V10 SimpleBackupCopyPolicy

Post by oleg.feoktistov »

Hi Michael,

Report/session for the jobs of type SimpleBackupCopyPolicy contain consolidated info on the last 24 hours.
That's why you see only the info on last result whenever you obtain a report on this job type.
And that explains the value of EndTime property with datetime in the past if you retrieve this info with Powershell.

Workaround for reports:

Code: Select all

$job = Get-VBRJob | where {$_.JobType -eq ‘SimpleBackupCopyPolicy’}

#Get job workers
$workers = $job.GetWorkerJobs() 

<#Get workers sessions. Jobs of type SimpleBackupCopyWorker, unlike those of SimpleBackupCopyPolicy, contain info on Full/Incremental runs, 
have much more history to show and reflect correct EndTime property.
#>

[Veeam.Backup.Core.CBackupSession]::GetByJob($workers.id)
Workaround for the last session:

Code: Select all

#Get worker job type
$jobtype = [Veeam.Backup.Model.EDbJobType]::SimpleBackupCopyWorker

#Retrieve the last session for worker job
[Veeam.Backup.Core.CBackupSession]::FindLastByJobType($jobtype) 

As for the info to be retrieved with Get-VBRBackupSession - we have noted it as the enhancement for the next product versions.

Thank you for the feedback and take care,
Oleg
xasz
Influencer
Posts: 13
Liked: never
Joined: May 21, 2017 8:03 pm
Full Name: Michael Schneider

Re: Veeam V10 SimpleBackupCopyPolicy

Post by xasz »

Hello Oleg,

thank you again for your help, but i don't understand how i could get it to work with your cmdlets.
Reports for the moment, i am not that into it, its just a thing what i have noticed, but what i need is the last successfull result of a SimpleBackupCopyPolicy job.
With

Code: Select all

[Veeam.Backup.Core.CBackupSession]::FindLastByJobType($jobtype) 
i can as far as i understood only get the really last or current session of one the SimpleBackupCopyPolicy jobs.
If i run it on one of my backup servers i get one of the currently running jobs, but can't control which one. So far i have not found any documentation about FindLastJobType and don't know how to filter.
What i need is to get the last successfull and finished Session for each of my SimpleBackupCopyPolicy Jobs.

For clarification: What i am doing is running a powershell script against each of my backup servers from my monitor server (In my case Paessler PRTG). The script now needs to check every job on the server, if it has successfull finished in the last 24 hours. Therefore i need to get last successfull Session and not the current running. If the script get's a current running job then i can't tell if it was successfull like 5 hours ago and just is now running again, because some of my jobs are running like 10-18 hours.
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Veeam V10 SimpleBackupCopyPolicy

Post by oleg.feoktistov » 1 person likes this post

Then, the first option with a bit of looping and filtering is a way to go:

Code: Select all

$jobs = Get-VBRJob | where {$_.JobType -eq ‘SimpleBackupCopyPolicy’}
foreach ($job in $jobs) {
$workers = $job.GetWorkerJobs() 
[Veeam.Backup.Core.CBackupSession]::GetByJob($workers.id) | where {$_.State -eq 'Stopped'} | Select Name, Result, EndTime -Last 1
} 
Thanks,
Oleg
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Veeam V10 SimpleBackupCopyPolicy

Post by oleg.feoktistov »

Please note that this has been addressed in v11a. For Backup Copy Jobs with immediate mode now you should see child sessions of SimpleBackupCopy worker job type in the output of Get-VBRBackupSession cmdlet. Thanks!
Post Reply

Who is online

Users browsing this forum: DanielJ and 23 guests