PowerShell script exchange
Post Reply
jcolonfzenpr
Enthusiast
Posts: 53
Liked: 33 times
Joined: Dec 30, 2021 1:16 am
Full Name: Jonathan Colon
Location: Puerto Rico
Contact:

Powershell - Backup job Secondary Target

Post by jcolonfzenpr »

Hello,

I am in the process of adding backup job configuration information to the AsbuiltReport.Veeam.VBR report.

Example:
https://technomyth.zenprsolutions.net/w ... eport.html

But I have encountered problems on the secondary target info.

Is there any way to extract information about the secondary target in a backup job through powershell?

https://technomyth.zenprsolutions.net/w ... Target.png

Code: Select all

PS C:\Users\jocolon> (Get-VBRJob -Name  "PHARMAX-HQ-SVR")                          

Job Name                  Type            State      Last Result  Description
--------                  ----            -----      -----------  -----------
PHARMAX-HQ-SVR            VMware Backup   Stopped    None         Created by PHARMAX\administrator at 6/29/2021 12:12 PM.


PS C:\Users\jocolon>
any help would be appreciated!
Jonathan Colon
https://techmyth.blog/
oleg.feoktistov
Veeam Software
Posts: 2021
Liked: 673 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell - Backup job Secondary Target

Post by oleg.feoktistov » 1 person likes this post

Hi Jonathan,

No official way to do it, but this .NET method is working:

Code: Select all

$job = Get-VBRJob -Name 'Backup Job 1'
[Veeam.Backup.Core.CBackupJob]::GetSecondDestinationJobs($job.Id)
Best regards,
Oleg
david.domask
Veeam Software
Posts: 2607
Liked: 610 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Powershell - Backup job Secondary Target

Post by david.domask » 2 people like this post

Ah, sorry to step in, but I do want to note that Secondary Jobs (Copy Jobs) have a set of properties about linked jobs, so you have to go about it a little backwards and process the secondary job and then do some logic.

LinkedJobs => returns CLinkedJob object
LinkedJobIDs => returns array of GUIDs for jobs added to Backup Copies
LinkdBackups => I suppose it should check for backup copies where source is added by backup, but I am having issues getting it to show linked backups
LinkedRepositories => returns repositories that are added as a source.

I don't know if GetSecondDestinationJobs will work for when you're sourcing a secondary job from a Repository, so you might try writing out some logic based on what the Secondary Jobs have in their linked items properties.

Tape is a lot easier as the linked items are returned under Objects in the VBRBackupToTapeJob object.
David Domask | Product Management: Principal Analyst
oleg.feoktistov
Veeam Software
Posts: 2021
Liked: 673 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell - Backup job Secondary Target

Post by oleg.feoktistov » 1 person likes this post

David is right, I completely forgot about the reversed way. As long as it works with the properties mentioned above, you won't need .NET methods here. Thanks!
jcolonfzenpr
Enthusiast
Posts: 53
Liked: 33 times
Joined: Dec 30, 2021 1:16 am
Full Name: Jonathan Colon
Location: Puerto Rico
Contact:

Re: Powershell - Backup job Secondary Target

Post by jcolonfzenpr »

Thanks to both of you, I was successful in extracting the information.
Jonathan Colon
https://techmyth.blog/
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests