PowerShell script exchange
Post Reply
TitaniumCoder477
Veteran
Posts: 316
Liked: 48 times
Joined: Apr 07, 2015 1:53 pm
Full Name: James Wilmoth
Location: Kannapolis, North Carolina, USA
Contact:

Creating recovery media ISOs from specific backup chains

Post by TitaniumCoder477 »

I have opened Case #04551496 but do not expect to get quick resolution there because of the "outside" (?) nature of this task, hence posting here as well...

I am the Senior Automation Engineer for a MSP, and I have expert level knowledge and experience with PowerShell. That said, I create unit tests for virtually all my automation because I am also fully human! If I am missing something simple, I apologize in advance!

I have created automation that will facilitate creating recovery media en mass via our RMM, but unfortunately it looks like the basic cmdlets are not operational...

Referencing Example 1 at https://helpcenter.veeam.com/docs/backu ... ml?ver=100

The process is simple:
1. Create a an object to contain the path
2. Get the desired computer
3. Create the recovery media, passing both the desired computer object and the path object

Before using these cmdlets in my automation, I wanted to make sure I could create the ISOs manually through the PowerShell CLI and observe (in order to handle in my automation) any potential exceptions. But the error message I am getting would seem to imply that the cmdlets are not working in their basic form, and I have a suspicion as to why...

Figure 1: My version of the example (manually entered, line by line, into PowerShell CLI for testing and observation)
Image

Figure 2: Backup copy chain that can't be used--my suspicion is that Veeam PowerShell cmdlet is trying to use
Image

Figure 3: Backup chain that CAN be used
Image

Figure 4-6: Demonstrate of successful creation via UI
Image
Image
Image

So as you can see above, I think what is happening is that Veeam's PowerShell cmdlet is trying to create the recovery media from a copy job or another source, rather than from the Backups > Disk > [redacted]-LBS-Desktops > LAPTOP115.[redacted].root backup chain. I can create a recovery media ISO from this chain through UI just fine.

So how do I tell Veeam what backup chain to use for the Add-VBRDiscoveredComputerRecoveryMedia cmdlet?
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Creating recovery media ISOs from specific backup chains

Post by oleg.feoktistov »

Hi James,

As far as I see, Add-VBRDiscoveredComputerRecoveryMedia accepts VBRDiscoveredComputer object, which mirrors the case in the UI when you create recovery media from a discovered computer under VBR inventory. The case with recovery media creation from backups is not implemented.
I also checked the code and, as it turns out, when the cmdlet is invoked, the execution method seeks for the last uncorrupted backup and creates recovery media from it. A good question is why it fires this exception in your case.
I raised this question with QA in parallel but would advise to communicate in scope of the support case also.
Will follow up once I get a reply.

Thanks,
Oleg
TitaniumCoder477
Veteran
Posts: 316
Liked: 48 times
Joined: Apr 07, 2015 1:53 pm
Full Name: James Wilmoth
Location: Kannapolis, North Carolina, USA
Contact:

Re: Creating recovery media ISOs from specific backup chains

Post by TitaniumCoder477 »

This morning I set about creating a workaround, as discussed with support on 04551496, whereby I check for the status of a backup job before I attempt to create the recovery media. Unfortunately, I ran into another problem.

Figure 1: The Get-VBRJob appears to be deprecated for agent backups

Code: Select all

$jobs = Get-VBRJob | Where { $_.Name -Match $jobNameRegexStr }
WARNING: This cmdlet is no longer supported for computer backup jobs. Use "Get-VBRComputerBackupJob" instead.
Figure 2: So I attempted to use Get-VBRComputerBackupJob

Code: Select all

$jobs = Get-VBRComputerBackupJob | Where { $_.Name -Match $jobNameRegexStr }
But this cmdlet doesn't provide the State property or anything like it so that I can view the current state of the job.

Figure 3: The documentation for the cmdlet

Code: Select all

https://helpcenter.veeam.com/docs/backup/powershell/get-vbrcomputerbackupjob.html?ver=100
This page says the Output Object is a VBRComputerBackupJob array, but I have looked through all the documentation and run searches but cannot find any page for that object. It doesn't appear on the Veeam PowerShell Types list where I would expect it to be, nor even on the Veeam PowerShell Enumerations list. I was going to review the documentation for the object/type to make sure I wasn't missing it somehow.
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Creating recovery media ISOs from specific backup chains

Post by oleg.feoktistov »

Right, VBRComputerBackupJob object is missing GetLastState() method. However, since it is the last session state for this job anyways,
you can obtain it by applying some filtering:

Code: Select all

$job = Get-VBRComputerBackupJob -Name 'AgentJob'
$sessions = Get-VBRComputerBackupJobSession | Where-Object {$_.JobId -eq $job.Id}
$lastSession = $sessions | select -Last 1
$lastSession | select JobId, @{n='JobName';e={$job.Name}}, Result, State 
As for the documentation gap, you can submit a feedback for the article clicking on "Send Feedback" at the bottom of the page.

Thanks,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests