- Newest
- Most votes
- Most comments
When restoring an EC2 instance using AWS Backup via PowerShell, you can control the instance's startup behavior by specifying the appropriate metadata parameters in your Start-BAKRestoreJob command.
To restore an EC2 instance that remains in a stopped state, you need to include the "InstanceInitiatedShutdownBehavior" parameter with a value of "stop" in your restore job metadata. This tells AWS Backup how to handle the instance after restoration.
Here's how you would structure your PowerShell command:
Start-BAKRestoreJob -RecoveryPointArn "arn:aws:backup:REGION:ACCOUNT_ID:recovery-point:RECOVERY_POINT_ID" ` -Metadata @{ "RestoreTo" = "EC2Instance"; "InstanceType" = "t2.medium"; # Or your preferred instance type "InstanceInitiatedShutdownBehavior" = "stop"; # Other required parameters like VpcId, SubnetId, etc. } ` -IamRoleArn "IAM_ROLE_ARN" ` -ResourceType "VirtualMachine" ` -CopySourceTagsToRestoredResource $false
By setting "InstanceInitiatedShutdownBehavior" to "stop", you're configuring the instance to remain in a stopped state after the restore process completes. This approach allows you to restore the EC2 instance without it automatically starting, giving you control over when to start the instance manually later if needed.
Sources
Customizing the Network Settings When Using AWS Backup to Restore VMware-Based Instances to Amazon EC2 | AWS re:Post
Restore a virtual machine using AWS Backup - AWS Backup
There is no Start-BAKRestoreJob metadata value that restores an EC2 recovery point as an instance that has never entered the running state.
The existing answer confuses two different EC2 behaviors. InstanceInitiatedShutdownBehavior = stop means that, after the instance is running, an operating-system shutdown command will stop rather than terminate an EBS-backed instance. AWS explicitly says that this attribute applies only to a shutdown initiated from inside the guest OS. It does not control the initial launch state.
For an EC2 recovery point, AWS Backup documents that the restore creates an AMI, an EC2 instance, the root and data volumes, and snapshots. Its accepted EC2 restore metadata includes InstanceInitiatedShutdownBehavior, but there is no launch stopped or do not start field. EC2 launch itself transitions through pending to running. Therefore, the strict requirement “remain stopped and never start” cannot be met by an EC2 restore job.
If the requirement is only that the final state be stopped, restore first and stop the created instance after the restore completes. For example, the PowerShell flow is:
$restoreJobId = Start-BAKRestoreJob @restoreParameters do { Start-Sleep -Seconds 15 $job = Get-BAKRestoreJob -RestoreJobId $restoreJobId if ($job.Status -in @('ABORTED', 'FAILED')) { throw "Restore job $restoreJobId ended with status $($job.Status): $($job.StatusMessage)" } } until ($job.Status -eq 'COMPLETED') $instanceId = ($job.CreatedResourceArn -split '/')[-1] Stop-EC2Instance -InstanceId $instanceId -Force
This still allows the restored instance to boot before it is stopped, so it is not suitable when “never start” is a security or data-integrity requirement. The role running the script also needs permission to describe the restore job and stop that specific restored instance.
Your related post says the actual goal is to recover the storage volumes and then delete the temporary EC2 instance. For that workflow, the cleaner design is to protect the required EBS volumes as EBS resources and restore an EBS recovery point to a new volume. An EBS restore creates a volume and does not launch an EC2 instance. This needs an EBS recovery point; it is a different restore path from restoring an existing EC2 recovery point.
AWS references:
answered 3 months ago
Relevant content
asked a year ago
- AWS OFFICIALUpdated 4 years ago

This does not work.