I want to restore my Amazon Elastic Compute Cloud (EC2) instance from an AWS Backup recovery point.
Short description
You can use the AWS Backup console or the AWS Command Line Interface (AWS CLI) to restore an Amazon EC2 instance.
When you restore a recovery point, AWS Backup creates a new EC2 instance from the instance's Amazon Machine Image (AMI). AWS Backup also restores Amazon Elastic Block Store (Amazon EBS) volumes that you associated with the instance during the backup.
Important: If you experience issues when you connect to your instance, then see How do I resolve connection and startup issues with my EC2 instance?
Resolution
Use the AWS Backup console to restore your instance
To use the AWS Backup console, see Use the AWS Backup console to restore Amazon EC2 recovery points.
Note: If you use the original instance profile, then you must grant AWS Backup the iam:PassRole permission.
Use the AWS CLI to restore your instance
Note: If you receive errors when you run AWS CLI commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.
Complete the following steps:
- To get the recovery point's Amazon Resource Name (ARN) from your backup vault, run the following list-recovery-points-by-backup-vault AWS CLI command:
aws backup list-recovery-points-by-backup-vault --backup-vault-name BACKUP-VAULT-NAME --output json --query 'RecoveryPoints[].[BackupVaultName,RecoveryPointArn]'
Note: Replace BACKUP-VAULT-NAME with the name of your backup vault.
- In the output of the list-recovery-points-by-backup-vault command, note the recovery point's ARN.
- To get the recovery point metadata, run the following get-recovery-point-restore-metadata AWS CLI command:
aws backup get-recovery-point-restore-metadata --backup-vault-name BACKUP-VAULT-NAME --recovery-point-arn RECOVERY-POINT-ARN > out.json
Note: Replace BACKUP-VAULT-NAME with your backup vault name and RECOVERY-POINT-ARN with the recovery point's ARN.
- Edit the recovery point metadata to include only the parameters that you require.
- Save the edited metadata as a .json file, such as ec2-restore-metadata.json.
- To use the metadata to restore the instance, run the following start-restore-job AWS CLI command:
aws backup start-restore-job \
--recovery-point-arn RECOVERY-POINT-ARN \
--iam-role-arn arn:aws:iam::ACCOUNT-ID:role/service-role/AWSBackupDefaultServiceRole \
--idempotency-token IDEMPOTENCY-TOKEN \
--resource-type EC2 \
--region REGION \
--metadata file://ec2-restore-metadata.json
Note: Replace RECOVERY-POINT-ARN with your recovery point's ARN and ACCOUNT-ID with your AWS account ID. Also, replace IDEMPOTENCY-TOKEN with a unique token and REGION with your AWS Region.