Skip to content

how to use Start-BAKRestoreJob?

0

I got the restore job to kick-off with

$BackupJob = Get-BAKBackupJobList | ? ResourceName -eq "testrestore"
$BackupMetadata = [see below] -RecoveryPointArn $BackupJob.RecoveryPointArn -BackupVaultName $BackupJob.BackupVaultName
$RestoreJobId = $BackupJob | Start-BAKRestoreJob -Metadata $BackupMetadata.RestoreMetadata

Note: where I said [see below], that was the command Get- BAK Recovery PointRestoreMetadata (without the spaces). But this AWS forum won't allow me to type that for some reason.

But, that failed with an error which could be seen in the web console

Network interfaces and an instance-level subnet ID may not be specified on the same request

So, I guess it comes down to the seemingly simple question of, what does it take to perform a restore using the Powershell command line? It is pretty straight-forward from the web console. It requires that I supply one answer and then it runs successfully. From the command line, there are all kinds arguments that need to be supplied that AWS already has and no clear indication of what is missing when it doesn't work.

asked a year ago217 views

2 Answers
0
Accepted Answer

I finally got it to work like this

$BackupJob = Get-BAKBackupJobList | ? ResourceName -eq "testrestore"
$BackupMetadata = Get-B{forbidden word}Metadata -RecoveryPointArn $BackupJob.RecoveryPointArn -BackupVaultName $BackupJob.BackupVaultName
# If we provide all metadata, it gives an error. All of the data that AWS needs is in the backup that it created. So, we shouldn't have to do any of this. CLI restore is seriously broken.
# Metadata must be provided as a hash.
$SelectMetadata = @{
    BlockDeviceMappings=$BackupMetadata.RestoreMetadata['BlockDeviceMappings']
    VpcId = $BackupMetadata.RestoreMetadata['VpcId']
    SubnetId = $BackupMetadata.RestoreMetadata['SubnetId']
}
$RestoreJobId = Start-BAKRestoreJob -Metadata $SelectMetadata -IamRoleArn $BackupJob.IamRoleArn -RecoveryPointArn $BackupJob.RecoveryPointArn -ResourceType $BackupJob.ResourceType
  • forbidden word = AK RecoveryPointRestore without the space. WTF?

To be a real restore of the virtual machine, more metadata would need to be added. But, I'm only trying to get the storage volumes out of it; so, I'm going to delete the EC2 instance when I'm done anyway. Now to figure out how to prevent it from automatically powering on at the end of restore. Seems kind of crazy that that is the default. Still have to remember that AWS was created with the assumption that people are using AWS for a web farm.

answered a year ago

0

To restore an EC2 instance using AWS Backup's Start-BAKRestoreJob command, you need to provide specific metadata parameters. The error you're receiving indicates that the required metadata is missing.

For EC2 instance restores, you'll need to include metadata that defines how the restored instance should be configured. While the exact metadata requirements aren't explicitly listed in the available information for EC2 specifically, you can obtain the necessary metadata values by using the Get-BAKRecoveryPointRestoreMetadata cmdlet.

Here's how you can approach this:

  1. First, identify the recovery point ARN for your backup:
$recoveryPoint = Get-BAKBackupJobList | Where-Object ResourceName -eq "testrestore" | Select-Object RecoveryPointArn
  1. Then, retrieve the required metadata for that recovery point:
$metadata = Get-BAKRecoveryPointRestoreMetadata -RecoveryPointArn $recoveryPoint.RecoveryPointArn
  1. Finally, use that metadata in your restore job:
Start-BAKRestoreJob -RecoveryPointArn $recoveryPoint.RecoveryPointArn -Metadata $metadata -IamRoleArn "arn:aws:iam::account:role/service-role/AWSBackupDefaultServiceRole"

The metadata requirements vary by resource type. For EC2 instances, you might need to specify parameters like subnet IDs, security groups, and instance type. The Get-BAKRecoveryPointRestoreMetadata cmdlet will provide you with the specific metadata values needed for your particular EC2 instance restore.
Sources
StartRestoreJob - AWS Backup

answered a year ago

  • This AI response does not work.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.