PowerShell script exchange
Post Reply
teltrop
Novice
Posts: 7
Liked: never
Joined: Sep 04, 2019 1:56 pm
Contact:

Powershell Backup Job Secondary Target

Post by teltrop »

Hello everyone,

I am currently working on an script that documents my backup infrastructure. Therefore I would like to know which backup jobs have a secondary target and if so what the target is.
I have tried to find my desired informations with the Get-VBRJob and the Get-VBRJobOptions command. But I just can not find what I am looking for.

Am I just blind or is there another way to get the information I want?

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

Re: Powershell Backup Job Secondary Target

Post by veremin »

What exact secondary job you'd like to enable? Backup copy? Thanks!
teltrop
Novice
Posts: 7
Liked: never
Joined: Sep 04, 2019 1:56 pm
Contact:

Re: Powershell Backup Job Secondary Target

Post by teltrop »

For both Backup copy and Backup to Tape job. But my intention is not to enable the secondary target rather just get the information if a secondary target option was chosen or not. And if so what target were chosen. Thanks
sasilik
Expert
Posts: 104
Liked: 13 times
Joined: Jun 12, 2014 11:01 am
Full Name: Markko Meriniit
Contact:

Re: Powershell Backup Job Secondary Target

Post by sasilik »

At leas for me it seems that they don't expose that info on job properties. I guess you should use GetVBRTapeJob, expand Object property and add the tape job as secondary target to all jobs in there.
chris.arceneaux
VeeaMVP
Posts: 667
Liked: 358 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Georgia, USA
Contact:

Re: Powershell Backup Job Secondary Target

Post by chris.arceneaux » 1 person likes this post

The link between Backup Job and Copy Job that you're searching for resides in the Copy Job metadata. Please see the code below for an example:

Keep in mind, the code below is not complete. Please test the code, make it your own, and modify it according to your use case.

Code: Select all

# Retrieve all Jobs
$allJobs = Get-VBRJob

# Retrieve all Backup Copy Jobs
$copyJobs = $allJobs | Where-Object {$_.JobType -eq "BackupSync"}

# Placing all Backup Jobs in an array
[System.Collections.ArrayList]$jobsArray = ($allJobs | Where-Object {$_.JobType -eq "Backup"}).name

# Loop through each copy job searching for linked jobs
foreach ($job in $copyJobs){
    # if the source of the copy job is another backup job
    if ($job.LinkedJobIds){
        foreach ($id in $job.LinkedJobIds){
            $matchedJob = $allJobs | Where-Object {$_.id -eq $id}
            # Remove job from array as it has a corresponding copy job
            $jobsArray.Remove($matchedJob.name)
        }
    }
}

# Output final array - any job still in the array does not have a corresponding copy job
$jobsArray
teltrop
Novice
Posts: 7
Liked: never
Joined: Sep 04, 2019 1:56 pm
Contact:

Re: Powershell Backup Job Secondary Target

Post by teltrop »

Thanks for the fast replys.

Your suggestions defently brought me on the right path to succsess. Now all thats left to do is to properly match the gathered informations.

Thank you all for your help.
Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests