Home / Blog / Software Development

Software Development

How to Recover Data from a Lost EC2 Instance on AWS

Lost an EC2 instance? Your data is often still safe on its EBS volume. Here is how to get it back.

In this article
  1. Is it possible
  2. Why instances fail
  3. The concept
  4. Steps
  5. Prevention
  6. Frequently asked questions

Many people assume data from a lost EC2 instance is gone for good. After more than a year of running websites on EC2, we found that recovery is usually possible, because the instance's EBS volume often still exists.

Key takeaways

  • Every EC2 instance has an EBS volume, and it often survives a failure.
  • Launch a new instance in the same Availability Zone and attach the old volume.
  • Take a snapshot first so you can always go back.
  • Avoid Auto Scaling settings that can remove your only instance.

Is data recovery possible?

Yes, in many cases. The key is that the volume, not the instance, holds your data.

Why instances get lost

Sudden instance failure

A running instance can fail with no apparent reason, with both health checks failing. In that situation the same instance often cannot be brought back, and AWS support may not be able to revive it either.

Auto Scaling Group misconfiguration

When you create an Auto Scaling Group you set Max, Min and Desired capacity. If the minimum or desired count is 0, a scale-in event can remove your instance.

The concept: EBS volumes persist

Every EC2 instance has an attached EBS volume. When an instance is lost or corrupted, the volume usually still exists. Think of a computer that is switched off while its hard drive stays intact. Volumes set to delete on termination are the exception, so check that setting.

Steps to recover the data

  • Take a snapshot of the old volume as a safety copy.
  • Create a new instance in the same Availability Zone as the old volume.
  • Stop the new instance right after it launches.
  • Detach the new instance's root volume. It is a blank drive you do not need.
  • Find the old volume. If there are several, use the creation date to pick the right one.
  • Attach the old volume to the new instance.
  • Set the old volume as the root device, using /dev/xvda or /dev/sda1. Otherwise the instance will not start.
  • Start the instance. It should boot with your old data.

Prevent it next time

  • Enable regular EBS snapshots or AWS Backup.
  • Review Auto Scaling Group minimum and desired counts.
  • Set termination protection on important instances.

Need help with cloud hosting, backups and support? See our hosting and server support services.

Frequently asked questions

Can I recover data if the volume was deleted?

Only if you have a snapshot or backup. Without one, a deleted volume cannot be recovered.

Does the new instance have to be in the same zone?

Yes. An EBS volume can be attached only to an instance in the same Availability Zone.

The Ucodice Team is a group of passionate developers, designers and strategists delivering web, mobile and software solutions to clients worldwide.

Ready to take the next step?

Explore our all ucodice services or tell us about your project. A senior member of our team will get back to you with clear next steps.

Let's start your project

Tell us what you want to build or grow. We'll reply within one business day with clear next steps.

Phone: 9560430495  ·  Email: contact@ucodice.com

Office: Ucodice Technologies, IHDP Business Park, Street Number 7, Sector 127, Noida, Uttar Pradesh 201304. Also serving Delhi NCR and clients worldwide.

Trusted and certified

  • Google PartnerCertified for Google Ads
  • Meta business PartnerCertified for Meta Ads
  • 4.3 / 5 on Google47 Google reviews
  • 4.9 / 5 on Freelancer.in245 reviews

Free consultation

Tell us about your project.

Get a free quote