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
- Go to EC2 service, In the left pane, select instances and select the instance you want to backup
- Stop the instance for consistent backup.
- In the detail(bottom) pane, switch to the storage tab and select the root volume.
- Click Actions, choose Create Snapshot
- Name your snapshot, and then click Create Snapshot
- 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
- Go to EC2 service, In the left pane, select the instance and Stop the instance,
- In the detail(bottom) pane, switch to Storage
- Make note of Root device details i.e.
/dev/sda1
(different for windows) - Now, In the left pane, click snapshots under Elastic Block store, Select the snapshot created in the Backup process above
- Click Actions, then Click create volume
- Ensure that the availability zone (AZ) matches your instance. Adjust the volume size if necessary, and add a tag named RestoreVol.
- Click create volume
Detach an existing volume
- Go to Instances in the left-hand menu, select the instance, and stop it if it isn’t already.
- In the Storage tab of the details pane, find and select the root volume.
- Click Actions, Detach Volume and confirm by clicking Detach.
Attach a new Volume
- Go to Volumes in the EC2 left-hand menu
- Find the RestoreVol volume you created, select it, and click Actions.
- Select your instance and set the device name to match the original root volume, such as
/dev/sda1
for Linux instances. - Click Attach Volume.
That’s it! The Instance HAS BEEN RESTORED. Start the instance and access as you usually would.