PowerShell script exchange
Post Reply
alfonsrv
Novice
Posts: 3
Liked: never
Joined: Mar 26, 2023 9:58 am
Contact:

Backup Copy Job Id does not match Sessions' JobId anymore

Post by alfonsrv »

Since Veeam v12 Backup Copy Job Id do not match the JobId in the Sessions anymore.

I have code that looks like this which used to work in v11 and now returns nothing. Unfortunately there is also no other unique attribute that allows for matching.
Why on earth would anyone at Veeam commit those breaking changes?

Code: Select all

function Get-XVBRBackupSession {
    Param(
        [Parameter(Mandatory=$true, Position=0)]
        [string] $JobId
    )
    return Get-VBRBackupSession | `
            Where-Object { $_.JobId -eq $JobId -And $_.State -eq "Stopped" } | `
            Sort-Object EndTime;
};

$Sessions = Get-VBRBackupCopyJob | ForEach-Object { Get-XVBRBackupSession -JobId $_.Id };
Has anyone found a way to work around this issue? I thought about regex matching the name like this, but seems dirty compared to a definitive technical identifier. I also had instances, where the job name within the sessions does not update, after renaming the original copy job.

Code: Select all

Get-VBRBackupSession | Where-Object { $_.JobName -Match "^$($JobName)(?:\\.*)?$" }
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Backup Copy Job Id does not match Sessions' JobId anymore

Post by oleg.feoktistov »

Hi,

I'll take time to discuss it internally in details, but at first glance looks like it changed because in v12 we decided not to reflect parent sessions for backup copy jobs as they don't hold any useful info on job runs besides 24 hours aggregated data. Instead, we reflect job worker sessions, which contain data on every job run. And due to architectural changes for backup copy jobs in v12, it was applied to both of the backup copy modes. If that's the case, we will need a wrapper cmdlet for sessions with fixed specification and parentJobId property anyway as: 1) Rolling it back doesn't solve the original issue, 2) Get-VBRBackupSession operates with internal core classes, so if breaking changes in business logic are introduced, there is a high chance that the output changes.

For now, the workaround is to get backup copy job workers and match sessions with their ids:

Code: Select all

$copyJob = Get-VBRBackupCopyJob
$jobConverted = Get-VBRJob | where {$_.Id -eq $copyJob.Id}
$jobWorkers = $jobConverted.GetWorkerJobs()
$sessions = Get-VBRBackupSession | where {$_.JobId -eq $jobWorkers.Id}
$sessions
Best regards,
Oleg
alfonsrv
Novice
Posts: 3
Liked: never
Joined: Mar 26, 2023 9:58 am
Contact:

Re: Backup Copy Job Id does not match Sessions' JobId anymore

Post by alfonsrv »

While it does make sense, it unfortunately introduces wide inconsistencies with the logic everywhere else; mainly speaking basically all other backup jobs that have a matching JobId within the session mirroring the actual parent job's Id.

From what I've read in the forums here, calling the internal .NET API as suggested by your PowerShell snippet (GetWorkerJobs()) is considered "unsupported" by Veeam.
Thanks for the workaround insights though.

Best, Alfons~
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests