PowerShell script exchange
Post Reply
PSDude
Novice
Posts: 3
Liked: 1 time
Joined: Jul 30, 2024 10:43 am
Full Name: Stu
Contact:

Script to perform instant recovery to vCenter

Post by PSDude »

Hi!

I've backed up a number of physical hosts using the Veeam Agent which includes enabling application-aware processing. My intention is to restore these into vCenter using a PowerShell script so that I can restore multiple machines at one time.

It looks like the cmdlet to perform the restore is Start-VBRViComputerInstantRecovery. One of the parameters it prompts for is RestorePoint. If I run Get-VBRRestorePoint, I don't see any of the hosts I've backed up using the above method, however if I use Get-VBRApplicationRestorePoint, I do. Great, or so I thought... I pop one of the machines into a variable but, the Start-VBRViComputerInstantRecovery cmdlet doesn't like what I'm feeding it.

Here's a little snippet of what I'm running:

Code: Select all

$VBRServer = "VeeamServer"
$VBRCreds = Get-Credential
$VIServer = "vCenterServer"
$RestorePoint = Get-VBRApplicationRestorePoint | Where {$_.Name -eq "SERVERNAME"} | Sort Descending | Select -First 1
Start-VBRViComputerInstantRecovery -RestorePoint $RestorePoint -Server $VIServer

I then get this error:

Code: Select all

Start-VBRViComputerInstantRecovery : Cannot bind parameter 'RestorePoint'. Cannot convert the "SERVERNAME" value of type
"Veeam.Backup.PowerShell.Infos.VBRApplicationRestorePoint" to type "Veeam.Backup.Core.COib".
At line:1 char:50
+ ... tart-VBRViComputerInstantRecovery -RestorePoint $RestorePoint -Server ...
+                                                     ~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Start-VBRViComputerInstantRecovery], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Veeam.Backup.PowerShell.Cmdlets.StartVBRViComputerInstant
   Recovery
Is there an alternative way of doing this?
david.domask
Veeam Software
Posts: 2751
Liked: 630 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Script to perform instant recovery to vCenter

Post by david.domask »

Hi Stu, welcome to the forums.

Can you share how you tried to get the restorepoint with Get-VBRRestorePoint? With Agent backups, please see the note on Get-VBRRestorePoint:
To get a list of restore points for a Veeam Agent job, you must provide the asterisks sign for the Name parameter value: Name "AgentJob*". Otherwise, the Get-VBRRestorePoint cmdlet will not return any restore points for the Veeam Agent job.
Going at this with strings is not the greatest in my experience, so usually I first fetch a CBackup object with Get-VBRBackup and pass that to the -Backup parameter on Get-VbrRestorePoint:

Code: Select all

PS C:\Users\david.LAB> $Backup = Get-VBRBackup -name "Vaw-app01"
PS C:\Users\david.LAB> $backup

Job Name                  Type            Creation Time               VM count
--------                  ----            -------------               --------
VAW-App01                 Windows Agen... 15.01.2024 13:25:09                1


PS C:\Users\david.LAB> Get-VBRRestorePoint -Backup $Backup

VM Name                   Creation Time          Type
-------                   -------------          ----
APP-01.lab.intern         15.01.2024 13:44:14    Full
app-01.lab.intern         08.05.2024 12:03:35    Increment
app-01.lab.intern         08.05.2024 12:14:44    Increment
Any of those resulting objects can be passed to the Start-VBRViComputerInstantRecovery -RestorePoint parameter. Try it out and let us know the result?
David Domask | Product Management: Principal Analyst
PSDude
Novice
Posts: 3
Liked: 1 time
Joined: Jul 30, 2024 10:43 am
Full Name: Stu
Contact:

Re: Script to perform instant recovery to vCenter

Post by PSDude »

Hi! Thank you for this!

Curiously, when I use Get-VBRRestorePoint -Name "AgentJob*" nothing is returned. I did also try with Get-VBRRestorePoint -Name "*AgentJob*"

Likewise, with Get-VBRBackup, nothing is returned. I have also tried

Get-VBRBackup -Name "AgentJob*"
Get-VBRBackup -Name "*AgentJob*"

and

Get-VBRBackup -Name "SERVERNAME"

However, I've just taken some of what you've said and come up with the following that seems to work:

$BackupJob = [Veeam.Backup.Core.CBackup]::getall() | Where {$_.JobName -like "JOBNAME"}
$RestorePoint = Get-VBRRestorePoint -Backup $BackupJob | Sort CreationTime -Descending | Select -First 1
Start-VBRViComputerInstantRecovery -RestorePoint $RestorePoint -Server $VIServer

Thank you for your help!
david.domask
Veeam Software
Posts: 2751
Liked: 630 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Script to perform instant recovery to vCenter

Post by david.domask »

Hi Stu,

Glad to hear you got it going, though I must inform that the first line uses an unsupported method. This one should in theory be stable, but I think if you're not seeing the backups returned even with Get-VBRBackup, it's best to open a Support Case and let Support review, as the cmdlets should return your agent backups as happened in my example.

If you end up opening a case, please share the case number; I recommend reproduce the issue prior to opening the case, note the date/time of the reproduce (and the user that you were running the cmdlets with), then include logs from the Veeam server itself. (Use the 3rd radio button, select the Veeam server itself. That should be enough for Support to start the investigation)
David Domask | Product Management: Principal Analyst
PSDude
Novice
Posts: 3
Liked: 1 time
Joined: Jul 30, 2024 10:43 am
Full Name: Stu
Contact:

Re: Script to perform instant recovery to vCenter

Post by PSDude » 1 person likes this post

Hi David, thanks for this. I've logged with ref #07366624.
Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests