How to restore a AWS EBS Volume from a Snapshot

How to restore a AWS EBS Volume from a Snapshot

Step-by-Step Guide

Table of Content

  1. Create Snapshot (or use existing one)
  2. Create a volume from a snapshot
  3. Detach the old root volume
  4. Attach the new root volume
  5. Conclusion

1. Create Snapshot (or use existing one)

In our test, we first create an EBS Snapshot from an existing EBS volume. If you already have a snapshot, which you want to restore, you can skip this step and continue with step 2.

  1. Navigate to your EC2 instance -> Storage and select your EBS volume.
  2. Click your EBS Volume and select Actions -> Create snapshot
  3. Description: My-EBS-Snapshot
  4. Click Create snapshot
  5. Under AWS Services EC2 -> Elastic Block Store -> Snapshots you can see the status of the newly created Snapshot
  6. Wait until the Snapshot status is Completed

2. Create a volume from a snapshot

  1. Under AWS Services EC2 -> Elastic Block Store -> Snapshots click on your newly created Snapshot
  2. Choose Actions and click Create volume from snapshot
  3. Volume type: Choose the same volume type as the old EBS volume e.q. gp3
  4. Size (GB): Choose the same size as the old EBS
  5. Availability Zone: Choose the same availability zone as the old EBS volume
  6. Click on Create volume
  7. Make not of the Volume-Id

3. Detach the old root volume

  1. Under AWS Services EC2 -> click on your EC2 instance -> Storage
  2. You can see under Root device details your current Root device name usually /dev/sda1. This is the root device, which means you have to stop the instance first, in order to be able to replace it.
  3. Keep note of the Device Name /dev/sda1 - we need it later, when we want to attach the new volume
  4. Stop the EC2 instance
  5. Select the EBS root volume -> Actions -> Detach volume

4. Attach the new root volume

  1. Find the new volume under EC2 -> Elastic Block Store -> Volumes
  2. Click Actions -> Attach volume
  3. Instance: Choose your EC2 instance-id
  4. Device name: /dev/sda1 This must be the same device name as before!
  5. Click Attach volume
  6. Start your EC2 instance
  7. Your new volume status should change from Available to In use

5. Conclusion

It's crucial to regularly practise your recovery plans. If you ever need need to restore your production EBS volume from a snapshot, you should not have to spend time researching how to do it. Instead, it is advisable, to have a step-by-step guide of the entire process. This is particularly important for production environments where time is limited and you may need to perform the recovery under pressure. I hope based on this guide, you can create your own step-by-step recovery plan for your production environment.