Bobcares Logo
Search Phone User Profile Emergency Contact
Bobcares Logo
Search Phone User Profile Emergency Contact
Emergency Contact Client Portal
SOLUTIONS
Product Engineering
MVP Build
MVP to Scale
Product Maintenance
Digital Transformation
Process Digitization & Automation
Systems Integration & Workflow Orchestration
Data Enablement & Decision Support
Application & Platform Modernization
Transformation Execution
AI Services
AI Readiness & Use-Case Discovery
AI Integration & Application Enablement
Intelligent Automation & AI Workflows
Infrastructure Management & Optimization
Always-On Infrastructure Management
Proactive Monitoring & Incident Prevention
Cloud Cost Control & Optimization (FinOps)
Outsourced IT & End-User Support
Managed Infrastructure Execution Support
DevOps & Automation Services
CI/CD & Release Automation
Infrastructure as Code & Platform Standardization
Reliability Engineering & Observability
DevSecOps Enablement
Cybersecurity
Security Assessment & Risk Posture
Threat Monitoring & Incident Response
Infrastructure & Cloud Security Hardening
Vulnerability Assessment & Penetration Testing (VAPT)
Backup, Disaster Recovery & BCP

Restore an EC2 instance from an AWS Backup with AWS CLI

by Jiji Jose | Aug 23, 2021 | Amazon Web Services (AWS), Latest | 2 comments

Please Note: This article is part of our historical archive. Because it was published a while ago, some of the information, links, or context may now be outdated.

One of the common queries we get from our AWS customers is something along the lines of ” how to restore an EC2 instance from an AWS Backup with AWS CLI”? We can help you with this!

As a part of our AWS Support Services, we often receive similar requests from our AWS customers.

Today, let’s see the steps followed by our Support Techs to help our customers to restore an AWS EC2 instance from an AWS Backup with AWS Command-Line Interface.

 

Restore an EC2 instance from an AWS Backup with AWS CLI

 
Now, let’s see the steps for restoring EC2 instance from an AWS Backup with AWS CLI:

  1. Firstly, list all the recovery points in the vault using the following list-recovery-points-by-backup-vault command. Note the RecoveryPointArn for the recovery point that we want to restore.
aws backup list-recovery-points-by-backup-vault --backup-vault-name Default --output json --query 'RecoveryPoints[].[BackupVaultName,RecoveryPointArn]'

2. To get the metadata of the Amazon EC2 instance, we need to run the get-recovery-point-restore-metadata command.

aws backup get-recovery-point-restore-metadata --backup-vault-name Default --recovery-point-arn arn:aws:ec2:eu-west-1::image/ami-012ab3456789c0123

3. Also copy the output of the above command. For example:

{
"BackupVaultArn": "arn:aws:backup:eu-east-1:987654321013:backup-vault:Default",
"RecoveryPointArn": "arn:aws:ec2:eu-west-1::image/ami-111ab9876c0123",
"RestoreMetadata": {
"CapacityReservationSpecification": "{\"CapacityReservationPreference\":\"open\"}",
"CpuOptions": "{\"CoreCount\":1,\"ThreadsPerCore\":1}",
"CreditSpecification": "{\"CpuCredits\":\"standard\"}",
"DisableApiTermination": "false",
"EbsOptimized": "false",
"HibernationOptions": "{\"Configured\":false}",
"IamInstanceProfileName": "ServerAccess",
"InstanceInitiatedShutdownBehavior": "stop",
"InstanceType": "t2.micro",
"KeyName": "BackupTesting",
"Monitoring": "{\"State\":\"disabled\"}",
"NetworkInterfaces": "[{\"AssociatePublicIpAddress\":true,\"DeleteOnTermination\":true,\"Description\":\"\",\"DeviceIndex\":0,\"Groups\":[\"sg-0babcd1234567890f\"],\"Ipv6AddressCount\":0,\"Ipv6Addresses\":[],\"NetworkInterfaceId\":\"eni-12345678a9b0cd1e2\",\"PrivateIpAddress\":\"192.0.2.206\",\"PrivateIpAddresses\":[{\"Primary\":true,\"PrivateIpAddress\":\"192.0.2.206\"}],\"SecondaryPrivateIpAddressCount\":0,\"SubnetId\":\"subnet-1a2b3c4d\",\"InterfaceType\":\"interface\"}]",
"Placement": "{\"AvailabilityZone\":\"eu-west-1b\",\"GroupName\":\"\",\"Tenancy\":\"default\"}",
"SecurityGroupIds": "[\"sg-0babcd1234567890f\"]",
"SubnetId": "subnet-1a2b3c4d",
"VpcId": "vpc-1a2b3c4d",
"aws:backup:request-id": "c1234567-ee7c-4896-beeb-ee123b456789"
}
}

4. Then edit the command output to keep only the following metadata fields and values:

{
"VpcId": "vpc-1a2b3c4d",
"Monitoring": "{\"State\":\"disabled\"}",
"CapacityReservationSpecification": "{\"CapacityReservationPreference\":\"open\"}",
"InstanceInitiatedShutdownBehavior": "stop",
"DisableApiTermination": "false",
"KeyName": "BackupTesting",
"CreditSpecification": "{\"CpuCredits\":\"standard\"}",
"HibernationOptions": "{\"Configured\":false}",
"EbsOptimized": "false",
"Placement": "{\"AvailabilityZone\":\"eu-east-1b\",\"GroupName\":\"\",\"Tenancy\":\"default\"}",
"aws:backup:request-id": "c1234567-ee7c-4896-beeb-ee123b456789",
"InstanceType": "t2.micro",
"NetworkInterfaces": "[{\"DeleteOnTermination\":true,\"Description\":\"Primary network interface\",\"DeviceIndex\":0,\"Groups\":[\"sg-0babcd1234567890f\"],\"Ipv6AddressCount\":0,\"Ipv6Addresses\":[],\"PrivateIpAddresses\":[{\"Primary\":true,\"PrivateIpAddress\":\"192.0.2.210\"}],\"SecondaryPrivateIpAddressCount\":1,\"SubnetId\":\"subnet-1a2b3c4d\",\"InterfaceType\":\"interface\"}]"
}

5. We must also change the primary private IP address in the metadata output if the original instance is still in use. For that, change the Primary PrivateIpAddress to a different IP address than what was originally returned by the get-recovery-point-restore-metadata command in the NetworkInterfaces metadata field.

6. Then we need to save the metadata into a JSON file. We can name the file ec2-restore-metadata.json.

7. Finally, run the start-restore-job command with –recovery-point-arn set to the RecoveryPointArn and –metadata set to the JSON file.

aws backup start-restore-job --region eu-west-1 --recovery-point-arn "arn:aws:ec2:eu-west-1::image/ami-111ab9876c0123" --iam-role-arn "arn:aws:iam::987654321012:role/service-role/AWSBackupDefaultServiceRole" --metadata file://ec2-restore-metadata.json

OR

Instead of using a JSON file, we can also define the instance metadata as parameters within the start-restore-job command. For example:

aws backup start-restore-job --region eu-west-1 --recovery-point-arn "arn:aws:ec2:eu-west-1::image/ami-111ab9876c0123" --iam-role-arn "arn:aws:iam::987654321013:role/service-role/AWSBackupDefaultServiceRole" --metadata '{"VpcId": "vpc-1a2b3c4d", "Monitoring": "{\"State\":\"disabled\"}", "CapacityReservationSpecification": "{\"CapacityReservationPreference\":\"open\"}", "InstanceInitiatedShutdownBehavior": "stop", "DisableApiTermination": "false", "KeyName": "BackupTesting", "CreditSpecification": "{\"CpuCredits\":\"standard\"}", "HibernationOptions": "{\"Configured\":false}", "EbsOptimized": "false", "Placement": "{\"AvailabilityZone\":\"eu-west-1b\",\"GroupName\":\"\",\"Tenancy\":\"default\"}", "aws:backup:request-id": "c1234567-ee7c-4896-beeb-ee123b456789", "InstanceType": "t2.micro", "NetworkInterfaces": "[{\"DeleteOnTermination\":true,\"Description\":\"Primary network interface\",\"DeviceIndex\":0,\"Groups\":[\"sg-0babcd1234567890f\"],\"Ipv6AddressCount\":0,\"Ipv6Addresses\":[],\"PrivateIpAddresses\":[{\"Primary\":true,\"PrivateIpAddress\":\"172.31.32.210\"}],\"SecondaryPrivateIpAddressCount\":1,\"SubnetId\":\"subnet-1a2b3c4d\",\"InterfaceType\":\"interface\"}]"}'

 

[Need help with more AWS queries? We’d be happy to assist]
 

Conclusion

 
To conclude, today we discussed the steps followed by our Support Engineers to help our customers to restore an EC2 instance from an AWS Backup with AWS CLI.

2 Comments

  1. Fazal
    Fazal on 2022-10-11 at 23:16

    how to use userData field .. I am getting Invalid BASE64 encoding of user data

    Reply
    • Hiba Razak
      Hiba Razak on 2022-10-12 at 09:16

      Hi,
      Please contact our support team via live chat(click on the icon at right-bottom)

      Reply

Submit a Comment Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How to Achieve ISO Compliance in Cloud Hosting
  • Managed IT Services Cost and Pricing Guide for 2026
  • AWS CloudWatch: Monitoring, Alerts, and Best Practices
  • How to Reduce Cloud Bills: 11 Practical Ways
  • Hybrid Cloud Management: Best Practices and Tools

Categories

  • Advanced Vulnerability
  • AI Automation
  • AI Services
  • AI Support
  • AIOps
  • Amazon Web Services (AWS)
  • Apache
  • API Integration
  • Application Development
  • Azure
  • Business Process Management
  • Business Process Reengineering
  • Cloud Cost Optimization
  • Cloud Management
  • Cloud-Native Application
  • Cloudflare
  • cPanel
  • cPanel migration
  • Cyberpanel
  • DDoS
  • Development Service
  • DevOps
  • DevOps Consulting
  • DevSecOps
  • Digital Transformation
  • DigitalOcean
  • DirectAdmin
  • Docker
  • Drupal
  • Ecommerce
  • Feedback Management Systems
  • Filezilla
  • FTP
  • Full-Stack Product Development
  • Google cloud platform
  • HAProxy
  • Headless CMS Integration
  • Hosting Support
  • Hybrid Cloud Management
  • IIS
  • Infrastructure Management & Optimization
  • Kubernetes
  • KVM
  • Laravel
  • Latest
  • Legacy Application Modernization
  • Linode
  • Litespeed
  • LXC/LXD
  • Magento
  • Managed cloud services
  • Managed IT Services
  • Microservices Architecture
  • Mobile App Development
  • MongoDB
  • Moodle
  • MySQL
  • NFS
  • Nginx
  • OnApp
  • Outsourced Support
  • OVH
  • ovirt
  • Performance Optimization & Monitoring
  • pfsense
  • Plesk
  • PostgreSQL
  • PowerDNS
  • Product Engineering
  • Proxmox
  • RedHat
  • Redis
  • SaaS Development
  • Sendmail
  • Server Administration
  • Server Management
  • Software Development
  • Software Testing
  • SQLServer
  • Technical Support
  • UI/UX
  • Virtualizor
  • VMware
  • VPN
  • Vulnerability Scanning
  • Vultr
  • Web Development
  • Windows
  • WordPress
  • WordPress Hosting
  • WordPressHA

Subscribe to our newsletter

Footer newsletter

Email inquiry@bobcares.com | Phone 1-800-383-5193

Solutions

  • Product Engineering
  • Digital Transformation
  • AI Services
  • Infrastructure Management & Optimization
  • DevOps & Automation Services
  • Cybersecurity

Services

  • Managed IT Services
  • Cloud Modernization Services
  • Custom Software Development Services
  • DevOps services
  • Business Process Management Services

Insights

  • Case Studies
  • Blog

Company

  • About Us
  • Our Partners
  • Careers
  • CSR
Product Engineering +
Web Development MVP to Scale Builds Microservices Architecture Agile & Dev Team Augmentation Mobile Apps Ecommerce UI/UX Design QA & Test Automation
Digital Transformation +
Legacy Modernization Workflow Automation Data-Driven Dashboards CRM / ERP Integration Business Process Re-engineering
AI Services +
AI & Machine Learning AIOps Intelligent Automation Business Intelligence & Analytics AI Installation & Compute
Infrastructure Management +
Cloud Setup Cloud Migration Managed Cloud Services Server & Hosting Cost Optimization Performance Optimization Outsourced Support
DevOps & Automation Services +
CI/CD Setup Kubernetes & Docker Infrastructure as Code Cloud-Native Migration DevSecOps
Cybersecurity & Compliance Services +
Security Hardening VAPT Incident Response Backup & DR

© 2026 Bobcares. All Rights Reserved.

  • Cookie Policy
  • |
  • GDPR
  • |
  • Privacy Policy
  • |
  • Terms of Service
  • LinkedIn
  • YouTube
  • Instagram
  • Facebook

Preview of the new Bobcares experience
NEW UPDATE
See What’s New
at Bobcares

Discover a faster, clearer view of our services and expertise.


Explore the New Experience
Arrow Right