PowerShell script exchange
Post Reply
aantonacci@shci.ca
Influencer
Posts: 21
Liked: never
Joined: Oct 19, 2020 7:42 pm
Full Name: Anthony Antonacci
Contact:

Get Objects from Backup Copy Job -

Post by aantonacci@shci.ca »

Hi,

I Setup a backup job to backup a VM
Then I setup a Backup Copy job, Add the BackupJOB as an object to the Backup-Copy-Job (so when the backup finishes it will call the backupcopyjob)

When i run queries on the job. i can't read the objects. so i can't figure out what copy job is associated to what job.
I noticed that these copy jobs are called "SimpleBackupCopyPolicy"

in the GUI, the Backup copy job has 1 Object (the backup job)
But when I do these they all return nothing...
Get-VBRJobobject -job $job
$job.LinkedJobs
$job.linkedjobids.guid <-- this works when its a backupsync type of job.
$job.GetObjectsInJob()

The only way I can figure out what copyjob the job is associated to is to read the last session and get the "name" . The name appears to include both jobnames
So "Daily30Local\Daily30offsite" then I split the name in half and use the name to backupjob info.
I don't really like this ... I'm sure there is a way to read objects that are included in the SimpleBackupCopyJob. (i can read objects in syncjob)
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Get Objects from Backup Copy Job -

Post by oleg.feoktistov »

Hi Anthony,

Check the solution provided here.

Thanks!
Oleg
aantonacci@shci.ca
Influencer
Posts: 21
Liked: never
Joined: Oct 19, 2020 7:42 pm
Full Name: Anthony Antonacci
Contact:

Re: Get Objects from Backup Copy Job -

Post by aantonacci@shci.ca »

! ! I was looking for this morning. (PS commands and search on this website)

Didn't Find it!

Code: Select all

$workerJobs = $job.GetWorkerJobs() 
foreach ($workerJob in $workerJobs) {
  $workerJob.LinkedJobIds
}
Did the job!!

Thanks so much!
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Get Objects from Backup Copy Job -

Post by oleg.feoktistov »

No problem. Glad to help you!
VKay3
Novice
Posts: 3
Liked: never
Joined: Oct 29, 2020 2:13 pm
Full Name: Kayce Harker
Contact:

Re: Get Objects from Backup Copy Job -

Post by VKay3 »

Good Morning, I am having a similar problem to the OP, except this solution did not quite resolve the issue for me.

Using

Code: Select all

$job = Get-VBRJob -Name 'CopyJob'
$workerJobs = $jobs.GetWorkerJobs() 
foreach ($workerJob in $workerJobs) {
  $workerJob.LinkedJobIds
}
will get me to the job in the Backup Copy repository, but does not get me to the sometimes multiple objects contained within the job that I want to report on.

We are using mirror backup copy jobs that are triggered as restore points are created. I already report on the local backups, but my team would also like to see the confirmation of start/end datetime when the backup copy job for each VM completed. Once I get to the main job inside the repository, what is the next command/method to retrieve the objects inside the job with each's associated data (start/end time, name, data transferred, etc)?
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Get Objects from Backup Copy Job -

Post by oleg.feoktistov »

Hi Kayce,

If you mean objects included into a source job, you need to get them directly from a source job.
A complete loop would look like that:

Code: Select all

$job = Get-VBRJob -Name 'BACKUP-COPY-MIRROR'
$workerJobs = $job.GetWorkerJobs() 
$allObjects = @()
foreach ($workerJob in $workerJobs) {
  $jobIds = $workerJob.LinkedJobIds
  foreach ($jobId in $jobIds) {
    $sourceJob = Get-VBRJob | where {$_.Id -eq $jobId}
    $objects = Get-VBRJobObject -Job $sourceJob
    $allObjects += $objects
  }
}
Thanks,
Oleg
VKay3
Novice
Posts: 3
Liked: never
Joined: Oct 29, 2020 2:13 pm
Full Name: Kayce Harker
Contact:

Re: Get Objects from Backup Copy Job -

Post by VKay3 »

This is about as far as I had been able to get on my own. When I pull the VBRObject, it does not seem to include the date information I can queue off to see how many backup copies were taken and when on a specific VM/copy.
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Get Objects from Backup Copy Job -

Post by oleg.feoktistov » 1 person likes this post

That's a whole different story. Dynamic data is held in sessions/task sessions. Here is an example for last job session:

Code: Select all

$job = Get-VBRJob -Name 'Mirror to SOBR*'
$workerJobs = $job.GetWorkerJobs() 
$allObjects = @()
foreach ($workerJob in $workerJobs) {
  $session = $workerJob.FindLastSession()
  $taskSessions = Get-VBRTaskSession -Session $session | select Name, @{n='StartTimeUTC';e={$_.Progress.StartTimeUTC}}, ` 
  @{n='StopTimeUTC';e={$_.Progress.StopTimeUTC}}, @{n='TransferedSize';e={$_.Progress.TransferedSize}}
  $allObjects += $taskSessions
}
$allObjects 
VKay3
Novice
Posts: 3
Liked: never
Joined: Oct 29, 2020 2:13 pm
Full Name: Kayce Harker
Contact:

Re: Get Objects from Backup Copy Job -

Post by VKay3 »

I think this was just what I needed! I should have come here sooner seeking assistance!! You are awesome :)
dcastera
Lurker
Posts: 2
Liked: never
Joined: Sep 24, 2020 7:28 pm
Full Name: Daniel Casterá
Contact:

Re: Get Objects from Backup Copy Job -

Post by dcastera »

Hi,
I need to list the full path of the files in a backup copy job, the closests I get is get de .vbk file of the vm an vapp, but not the full path. do any one have a powershell script to get this?
thanks in adavance
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Get Objects from Backup Copy Job -

Post by oleg.feoktistov »

Hi Daniel,

You may find this script useful. Although, it might get a bit tricky if it comes to Scale-Out repositories, but feel free to ask any questions if needed.

Thanks,
Oleg
dcastera
Lurker
Posts: 2
Liked: never
Joined: Sep 24, 2020 7:28 pm
Full Name: Daniel Casterá
Contact:

Re: Get Objects from Backup Copy Job -

Post by dcastera »

Hi Oleg, thanks for your reply
I have already tried that script but it did not work for me, it is probably as you say, the files are in a scale-out, and therefore it does not work correctly. What do you recommend me?
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Get Objects from Backup Copy Job -

Post by oleg.feoktistov »

Hi Daniel,

Can you, please, elaborate on the exact problem? I tried the very same script explicitly on jobs targeted to SOBR with multiple extents and it worked. The only thing that might feel confusing is displaying storages, whose block were copied/moved to capacity tier. As per SOBR architecture, when offloading data to capacity tier, backup files with metadata are also preserved on source extents. So, powershell refers the location of these preserved dummy files rather than data blocks themselves. The property, which might help you recognise offloaded ones is ExternalContentMode:

Code: Select all

$backup = Get-VBRBackup 'Backup to SOBR'
$restorePoints = Get-VBRRestorePoint -Backup $backup
foreach ($restorePoint in $restorePoints) {
   $storage  = $restorePoint.FindStorage()
   $storage | select @{n='Path';e={$_.PartialPath.ToString()}}, ExternalContentMode
}
So, to the custom object in the script I referenced above you would need to add:

Code: Select all

storageMode = $restorePoint.FindStorage().ExternalContentMode
The caveat here is that it doesn't work with restore points copied to capacity tier - content mode stays internal.
But we are planning to allow retrieving restore points from cloud tiers specifically in one of the post-v11 releases.

Hope it helps,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests