# How to restore a AWS EBS Volume from a Snapshot

# 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`.
1. Click your `EBS Volume` and select `Actions` -> `Create snapshot`
1. `Description`: My-EBS-Snapshot
1. Click `Create snapshot`
1. Under AWS Services `EC2` -> `Elastic Block Store` -> `Snapshots` you can see the status of the newly created `Snapshot`
1. 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`
1. Choose `Actions` and click `Create volume from snapshot`
1. `Volume type`: Choose the same volume type as the old EBS volume e.q. `gp3`
1. `Size (GB)`: Choose the same size as the old EBS
1. `Availability Zone`: Choose the same availability zone as the old EBS volume
1. Click on `Create volume`
1. Make not of the `Volume-Id`

# 3. Detach the old root volume
1. Under AWS Services `EC2` -> click on your `EC2 instance` -> `Storage`
1. 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. 
1. **Keep note of the Device Name** `/dev/sda1` - we need it later, when we want to attach the new volume
1. `Stop` the EC2 instance
1. 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`
1. Click `Actions` -> `Attach volume`
1. `Instance`: Choose your EC2 instance-id
1. `Device name`: `/dev/sda1` **This must be the same device name as before!**
1. Click `Attach volume`
1. Start your EC2 instance
1. 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.



