-
- Novice
- Posts: 6
- Liked: never
- Joined: Sep 19, 2017 1:49 pm
- Full Name: Heath Mason
- Contact:
PowerShell script to pull backup jobs and related copy/tape jobs
Trying to put together a reports of all our backup jobs and all secondary jobs (copy/tape). Looking to see if there's a PowerShell command/script out there that can assist.
-
- Veeam Software
- Posts: 2346
- Liked: 555 times
- Joined: Jun 28, 2016 12:12 pm
- Contact:
Re: PowerShell script to pull backup jobs and related copy/tape jobs
Hi @hm-hmason,
Before we get at this with Powershell, may I ask if our VeeamOne report is suitable for you?
https://helpcenter.veeam.com/docs/one/r ... ry&ver=120
I think this is what you're looking for mostly and I think it's easier.
You can pull the individual jobs with the relevant Get cmdlets: https://helpcenter.veeam.com/docs/backu ... er=120#get
So you'd find each type of job and just run those for the list, but I get this might be a bit putzy for normal use.
The main goal is to just find those backups _without_ a secondary target? Or just a job inventory?
Before we get at this with Powershell, may I ask if our VeeamOne report is suitable for you?
https://helpcenter.veeam.com/docs/one/r ... ry&ver=120
I think this is what you're looking for mostly and I think it's easier.
You can pull the individual jobs with the relevant Get cmdlets: https://helpcenter.veeam.com/docs/backu ... er=120#get
So you'd find each type of job and just run those for the list, but I get this might be a bit putzy for normal use.
The main goal is to just find those backups _without_ a secondary target? Or just a job inventory?
David Domask | Product Management: Principal Analyst
-
- Novice
- Posts: 6
- Liked: never
- Joined: Sep 19, 2017 1:49 pm
- Full Name: Heath Mason
- Contact:
Re: PowerShell script to pull backup jobs and related copy/tape jobs
I am aware that I could probably get what I 'm looking for from Veeam One but unfortunately, we do not have that currently. What I am trying to get is a list of all our backup jobs and a relation to any copy/tape jobs that are associated with them. I'll take a look at the Get cmdlets and see what I can pull. Thanks.
-
- Veeam Software
- Posts: 2346
- Liked: 555 times
- Joined: Jun 28, 2016 12:12 pm
- Contact:
Re: PowerShell script to pull backup jobs and related copy/tape jobs
Got it, thanks for the clarification.
You will need to do this "somewhat" backwards, as the relationship with powershell for secondary jobs to source jobs is the LinkedJobs or the LinkedJobIds property of CJob objects.
My examples below are from a Backup Copy job, and I'm checking the Backup Copy for its LinkedJobs and LinkedJobId properties:
So you will need to design a workflow that:
1. Collects all the source Image Level Backup Jobs to an array $SourceJobs (VMware and HyperV Backups)
2. Collects the secondary jobs (Backup Copies, Tape Jobs) and add them to an array $SecondaryJobs
3. Start an empty array for $JobsAndSecondaryReport
3. Start a ForEach loop over $SourceJobs and check in order:
3a. For Backup Copies Is the current Job ID in the LinkedJobIds or LinkedJobs.JobId lists?
3b. For Tape Jobs, is the current Job ID in the Objects property list? (You may want to build an array of this outside of the ForEach loop for speed purposes, but it's not super expensive call to do in the loop)
3c. If the SourceJob.Id is in either list from 3a or 3b, it means that source job is in secondary jobs, so we will build a PSCustomObject that has three properties:
Source Job Name
Backup Copy Job Name
Tape Job Name
If the source job ID is in either 3a or 3b (or both), you will simply set the property on the PSCustomObject to be that job-name for the relevant property.
3d. Add the resulting PSCustomObject to the $JobsAndSecondaryReport array
Once the Foreach loop is done, you'll have your list of associations from source jobs to secondary.
You will need to do this "somewhat" backwards, as the relationship with powershell for secondary jobs to source jobs is the LinkedJobs or the LinkedJobIds property of CJob objects.
My examples below are from a Backup Copy job, and I'm checking the Backup Copy for its LinkedJobs and LinkedJobId properties:
Code: Select all
PS C:\Users\Administrator> $job = Get-VBRJob -name 'ps-exclude-test'
PS C:\Users\Administrator> $job.LinkedJobs
Info : Veeam.Backup.Model.CLinkedObjectInfo
OrderNo : 0
Id : 89e7223e-6a7b-482b-92e1-701c3da35cb2
JobId : de6d2523-0db8-4913-8fd6-56d522efd785
LinkedJobId : c1b0bf4c-39d2-4ec1-80d6-e4444de078ca
CreationTime : 8/4/2023 1:09:42 PM
PS C:\Users\Administrator> $job.LinkedJobIds
Guid
----
c1b0bf4c-39d2-4ec1-80d6-e4444de078ca
1. Collects all the source Image Level Backup Jobs to an array $SourceJobs (VMware and HyperV Backups)
2. Collects the secondary jobs (Backup Copies, Tape Jobs) and add them to an array $SecondaryJobs
3. Start an empty array for $JobsAndSecondaryReport
3. Start a ForEach loop over $SourceJobs and check in order:
3a. For Backup Copies Is the current Job ID in the LinkedJobIds or LinkedJobs.JobId lists?
3b. For Tape Jobs, is the current Job ID in the Objects property list? (You may want to build an array of this outside of the ForEach loop for speed purposes, but it's not super expensive call to do in the loop)
3c. If the SourceJob.Id is in either list from 3a or 3b, it means that source job is in secondary jobs, so we will build a PSCustomObject that has three properties:
Source Job Name
Backup Copy Job Name
Tape Job Name
If the source job ID is in either 3a or 3b (or both), you will simply set the property on the PSCustomObject to be that job-name for the relevant property.
3d. Add the resulting PSCustomObject to the $JobsAndSecondaryReport array
Once the Foreach loop is done, you'll have your list of associations from source jobs to secondary.
David Domask | Product Management: Principal Analyst
-
- Lurker
- Posts: 1
- Liked: never
- Joined: Sep 18, 2024 6:19 am
- Full Name: T.Bersch
- Contact:
Powershell Skript for Secondary Targets
Hello everyone,
I have the problem that we have a lot of backups in use. I am still very new to the company and unfortunately I don't have an overview of whether a secondary target has been set up for each backup job.
The solutions I have currently found have unfortunately not helped me.
Does anyone have a solution that allows me to check each backup job to see if it has a secondary target set up? If none is set up, I want it to be ejected.
Thank you all for your support!
I have the problem that we have a lot of backups in use. I am still very new to the company and unfortunately I don't have an overview of whether a secondary target has been set up for each backup job.
The solutions I have currently found have unfortunately not helped me.
Does anyone have a solution that allows me to check each backup job to see if it has a secondary target set up? If none is set up, I want it to be ejected.
Thank you all for your support!
-
- Veeam Software
- Posts: 2346
- Liked: 555 times
- Joined: Jun 28, 2016 12:12 pm
- Contact:
Re: PowerShell script to pull backup jobs and related copy/tape jobs
Hi tbbnt24, welcome to the forums.
I've merged your post with an existing topic on the subject, please see my answer above. There is a way to do it, but you have to do it a bit "backwards" and poll from the Backup Copy Jobs and check their LinkedJobs or LinkedJobId properties.
Similarly, consider VeeamOne as there are reports that can help monitor your backups and determine which do and do not have copies:
https://helpcenter.veeam.com/docs/one/r ... ml?ver=120
https://helpcenter.veeam.com/docs/one/r ... ml?ver=120
I've merged your post with an existing topic on the subject, please see my answer above. There is a way to do it, but you have to do it a bit "backwards" and poll from the Backup Copy Jobs and check their LinkedJobs or LinkedJobId properties.
Similarly, consider VeeamOne as there are reports that can help monitor your backups and determine which do and do not have copies:
https://helpcenter.veeam.com/docs/one/r ... ml?ver=120
https://helpcenter.veeam.com/docs/one/r ... ml?ver=120
David Domask | Product Management: Principal Analyst
Who is online
Users browsing this forum: No registered users and 19 guests