Snapshot: – basically it created to restore the instance at the particular point of time, whenever you choose. It contains data and configuration files.
Whenever we are doing some testing on the server (like deploying some applications, updating/upgrading OS) may or may not succeed all the time, to avoid loss of data we took a snapshot, if it is a success no issue, if it fails we can get it back the instance by using snapshot.
Let me explain how to create a snapshot and how to restore the instance.
- Login to AWS Console,
- Go to service option on the top left side, and select EC2 services.
- Go to volumes on an EC2 console, select the VOLUME of the instance, suppose if we have 100’s instances, it’s difficult to identify which is the right instance volume, for that go to instance copy the instance ID which you want, paste in the search bar in volumes screen.
- Then click on the action button, select CREATE SNAPSHOT.
It will ask you name and description, then click on create.
Think that instance got failed, unable to use or power on.
- Go to INSTANCE, select the instance and click on action select INSTANCE STATE select STOP.
Then it will ask you confirmation click on stop.
- Then go to the VOLUME, select INSTANCE VOLUME, click on action, select the DETACH VOLUME, it will detach the volume from the machine, then after you can delete the volume also.
Then it will ask you confirmation, click on YES DETACH.
- Go to SNAPSHOT from the ec2 console, select the right snapshot, click on action, click on CREATE VOLUME.
Note:- while creating volume the availability zone should be same as instance availability zone.
Note:- If the volume not in the same availability zone, you can’t attach the volume to the respective instance.
Now we created volume from the snapshot, then we have to attach a volume to the instance.
- Go to VOLUME, select volume, click on action, select ATTACH VOLUME.
Then selects the instance and give dive path then click on attach
Note: – device should be /dev/sda1
- Then go to an instance and power on it will work as usual.