What is EBS Snapshot in AWS and how to use it?

What is EBS Snapshot in AWS and how to use it?

·

2 min read

What is EBS Snapshot in AWS?

Amazon Elastic Block Store (Amazon EBS) snapshots are point-in-time copies of Amazon EBS volumes. Snapshots are saved in Amazon S3 and are incremental, meaning that only the blocks that have changed since your last snapshot are saved. This makes them very efficient to store and use. You can use snapshots to back up your data, as a data source for creating new Amazon EBS volumes, and to help you migrate data between AWS regions.

Amazon S3 is region specific, so with the help of snapshots, we can deploy another EBS Volume in another availability zone of the same region.

The below diagram will help you to understand more.

But How to use it? Let see…

  • Go to the AWS console and create a new EC2 instance.

  • Add one more EBS to that instance, here I added 10 GB of EBS and clicked on Launch instance.

  • Now SSH to that instance and check the connected EBS.

  • Now format that EBS and make a file system in it.

  • Now mount this EBS block with a directory to use it, type the below commands
mkdir snapshot-ebs
mount /dev/xvdb /snapshot-ebs

  • now go into that EBS directory, and make some data in it. I am using yes command, make it.

now we have a file named file.txt of size 1.4GB.

  • Now we're going to take a snapshot of it. Before that I am showing you my snapshot page, there is no previous snapshot available.

  • Now open the EBS Volume page and select the EBS volume which has data present and going to be snapped.

  • Give a name to that snapshot.

'

  • Now select that snapshot in the snapshot console and create an EBS volume with the snapshot. Make sure the volume should be in the same Availability zone where EC2 is present.

  • Now attach that newly created EBS to the EC2.

  • Now type the below commands
$ lsblk # it show connected ebs
$ file -s /dev/xvdf # to check if there is any filesystem already present

# now again mount it with a directory
$ mkdir new-snap-dir
$ mount /dev/svdf /new-snap-dir/

  • Done!! Here you can see that 1.4 GB file is also present in this EBS volume.