How To Backup And Restore Your EC2 Instance

When working with EC2 instances, there may be times when you need to create an on-demand backup before making changes, such as updates or driver installations. If everything goes smoothly, that’s great. But if something goes wrong, you’ll need to restore the instance from the backup.

Here’s a simplified process for doing that:

BACKUP:
1. Create a snapshot of the root volume.

RESTORE:
1. Create a volume from the snapshot.
2. Detach the existing root volume.
3. Attach the newly restored volume.

Now let’s go over these steps.

Backup: Create a snapshot of the root volume
  1. Go to EC2 service, In the left pane, select instances and select the instance you want to backup
  2. Stop the instance for consistent backup.
  3. In the detail(bottom) pane, switch to the storage tab and select the root volume.
  4. Click Actions, choose Create Snapshot
  5. Name your snapshot, and then click Create Snapshot
  6. Take note of the snapshot ID that appears at the top of the screen—this will be important later.
Restore: Recovering from the Snapshot
Create a Volume
  1. Go to EC2 service, In the left pane, select the instance and Stop the instance,
  2. In the detail(bottom) pane, switch to Storage
  3. Make note of Root device details i.e. /dev/sda1 (different for windows)
  4. Now, In the left pane, click snapshots under Elastic Block store, Select the snapshot created in the Backup process above
  5. Click Actions, then Click create volume
  6. Ensure that the availability zone (AZ) matches your instance. Adjust the volume size if necessary, and add a tag named RestoreVol.
  7. Click create volume
Detach an existing volume
  1. Go to Instances in the left-hand menu, select the instance, and stop it if it isn’t already.
  2. In the Storage tab of the details pane, find and select the root volume.
  3. Click Actions, Detach Volume and confirm by clicking Detach.
Attach a new Volume
  1. Go to Volumes in the EC2 left-hand menu
  2. Find the RestoreVol volume you created, select it, and click Actions.
  3. Select your instance and set the device name to match the original root volume, such as /dev/sda1 for Linux instances.
  4. Click Attach Volume.

That’s it! The Instance HAS BEEN RESTORED. Start the instance and access as you usually would.

Leave a Comment

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

Scroll to Top