EBS Snapshots
Overview
Amazon Elastic Block Storage is a feature-rich storage solution provided by AWS. To ensure timely and secure backups of these EBS volumes, AWS provides the EBS Snapshot facility. Let's deep dive into what EBS Snapshots are and how you can use them to backup EBS Volumes.
EBS Snapshots
An Amazon Elastic Block Storage (EBS) Volume is the storage device attached to an Amazon EC2 Instance. EBS Volumes are generally used as the primary storage for file systems or databases. Multiple EBS Volumes can be attached to a single EC2 Instance.
EBS Snapshots** are an easy way to back up your EBS Volumes to Amazon S3. These snapshots are incremental backups, ie., they contain only the difference in data between your last EBS snapshot and the current EBS Volume's data.
Each EBS Snapshot contains all the configurations required to restore your data to a new EBS Volume. The use of incremental backups instead of full backups reduces the time required to create a snapshot and saves on storage costs by not duplicating data.
Let's explore the use cases, benefits, and limitations of EBS Snapshots.
Use Cases of EBS Snapshots
EBS Snapshots are essential for backing up EBS volumes but they have a few other uses as well. Let's explore all of these use cases.
1. Data Backup
The most common use case of EBS Snapshots is taking backups of EBS Volumes. EBS Snapshots can be then used to restore the backed-up data on existing or new EBS Volumes. These snapshots can be easily shared to a different region within the same AWS Account or to a completely different AWS Account.
2. Disaster Recovery
EBS Snapshots with the help of cross-region replication enable disaster recovery of EC2 Instances. In the event of a disaster, new EC2 Instances can be created in an alternate region and the EBS Snapshots can be used to restore data to the EBS Volumes.
3. Data Retention and Auditing Requirements
EBS Snapshots can also be used for cheap, long-term data retention. This is especially useful to keep in line with certain auditing requirements established in more data-sensitive industries.
4. Replicating Production Environment
EBS Snapshots are useful when you are replicating your production environment. When you need to load a copy of production data into your development or testing environments, you can copy the EBS Snapshots from your Production environment and use these snapshots to restore the data.
Benefits of EBS Snapshots
Let's look at a few of the benefits of using EBS Snapshots:
1. Low Cost
EBS Snapshots are cheaper than EBS Volumes, and also take up lesser storage. You can use EBS Snapshots to backup your database or file system's data and restore it whenever required.
2. Time-Efficient and Multi-Volume Support
EBS Snapshots, once configured, can be taken automatically by AWS. The snapshot process is very quick and does not cause any resource crunch on the EBS Volume. AWS also allows you to automatically take snapshots of multiple EBS Volumes attached to a single EC2 Instance at the same time.
3. Integration With AWS Ecosystem
Since EBS Snapshots is a service provided by AWS, it is tightly integrated into its ecosystem. The snapshots are stored on Amazon S3, which is an extremely low-cost storage solution. Further, EBS Snapshots has integrations with Amazon Data Lifecycle Manager, allowing you to automate the snapshot lifecycle.
4. Easily Shareable
EBS Snapshots come with the flexibility to be easily duplicated to different regions in the same AWS Account, shared to different AWS Accounts, or made available to the public.
Limitations of EBS Snapshots
Now that we have understood the use cases and the benefits of EBS Snapshots, let's take a look at some of the limitations:
1. Potential Data Loss
Certain applications or databases store data in memory, either to serve as a cache or achieve better read performance. When you take an EBS Snapshot, AWS will not automatically flush the memory and add it to the snapshot. Hence this might result in a data loss. It's always recommended that you flush the memory (either programmatically or by shutting down the instance) before you take an EBS Snapshot.
2. Not Transferrable
EBS Snapshots are stored in Amazon S3 in the blob format. These snapshots are not transferrable outside AWS, nor can be used to restore data to a server or an instance from another cloud provider.
3. Duplication of Incremental Snapshots
Depending on the number of EBS Volumes you need to take a backup of and the period configured, the number of EBS snapshots can grow exponentially. Its recommended that you setup a lifecycle policy to regularly delete older versions of EBS Snapshots.
How To Create, Copy, and Delete AWS EBS Snapshots
AWS EBS Snapshots can be created, copied and deleted using the AWS Console or the AWS CLI.
For detailed instructions on how to perform various operations on AWS EBS Snapshots and the commands for the AWS CLI, please refer to the official AWS Documentation linked here.
Pre-Requisites
- AWS Account
- Amazon EC2 Instance
How To Create AWS EBS Snapshots Using AWS Console
- Login to your AWS Account.
- Open the AWS Console. Search for "EC2" in the Search Bar. Select EC2. In the navigation pane, choose Snapshots.
- Click the Create snapshot button.
- In the "Create snapshot" page:
- For the "Resouce type", select "Volume".
- For the "Volume ID", select the EBS Volume ID you want to take a snapshot of.
- Optionally, add a "Description".
- Click the Create snapshot button. In a few mins, your AWS EBS Snapshot will be ready.
How To Copy AWS EBS Snapshots Using AWS Console
- Login to your AWS Account.
- Open the AWS Console. Search for "EC2" in the Search Bar. Select EC2. In the navigation pane, choose Snapshots.
- Select the AWS EBS Snapshot you want to copy. Click Actions and then choose Copy snapshot.
- Select the AWS Region that you want to copy the AWS EBS Snapshot to.
- Click Copy snapshot.
How To Delete AWS EBS Snapshots Using AWS Console
- Login to your AWS Account.
- Open the AWS Console. Search for "EC2" in the Search Bar. Select EC2. In the navigation pane, choose Snapshots.
- Select the AWS EBS Snapshot you want to delete. Click Actions and then choose Delete snapshot.
How To Reduce Your AWS Bill Using EBS Snapshots?
When used efficiently, EBS Snapshots enable you to reduce your AWS Bill. Let's understand how you can achieve this:
1. Switch To EBS Snapshot Based Backup
For EC2 Instances which serve as databases, or where the storage is critical but the operating system isn't as critical, then only the EBS Volume can be backed up using EBS Snapshots instead of backing up the entire EC2 Instance using Amazon AMI. This will save costs as EBS Snapshots take up lesser space compared to AMIs, and have a lower cost.
2. Delete Unattached EBS Volumes
When you delete an Amazon EC2 Instance, depending on your instance's settings, the EBS Volume can remain unattached. In case you need to still store this EBS Volume, then the data can be backed up using EBS Snapshots and the unattached EBS Volume can be deleted to save costs.
3. Archive Old EBS Snapshots
Older EBS Snapshots that are no longer required can be deleted to reduce your AWS Bill, depending on your application's requirements.
Make EBS Snapshots Public or Private
You can easily make an EBS Snapshot public or private using the AWS Console.
Pre-Requisites
- AWS Account
- An Amazon EBS Snapshot
Steps
- Login to your AWS Account.
- Open the AWS Console. Search for "EC2" in the Search Bar. Select EC2.
- From the EC2 Dashboard, go to Snapshots.
- Select the snapshot you want to make public or private.
- You can now modify the snapshot's permission.
- To share the snapshot publicly with all AWS accounts, choose Public.
- To share the snapshot privately with specific AWS accounts, choose Private. Then, in the Sharing accounts section, choose Add account, and enter the 12-digit account ID (without hyphens) of the account to share with.
- Choose Save changes.
Difference Between EBS Snapshots and AMI Images
EBS Snapshots and AMIs are two different backup offerings by AWS. Let's look at the differences between these two:
Characteristic | Amazon AMI | Amazon EBS SnapshotI |
---|---|---|
AWS Service | Amazon EC2 Instance is backed up along with the associated EBS Volume(s) | Only Amazon EBS Volume(s) are backed up |
Processing Time | AMIs take relatively longer to complete | After the first snapshot has been taken, EBS Snapshots take a shorter time than AMIs since the backups are incremental |
Storage Size | AMIs take up more storage compared EBS Snapshots as the entire EC2 Instance as well as the EBS Volume is backed up | EBS Snapshots take up much lesser space compared to AMIs |
Conclusion
- In this article, you learnt about EBS Snapshots and how they work.
- We took a look at the use cases of EBS Snapshots - data backup, disaster recovery, data retention, and replicating production environments.
- Then we explored the benefits of EBS Snapshots - low cost, time efficiency, integration with AWS services, and easy shareability.
- We understood the limitations of EBS Snapshots - potential data loss, not transferrable, and duplication of incremental snapshots.
- We went through the steps to create, copy, and delete an EBS Snapshot using the AWS Console.
- You learnt some tips on how you can reduce your AWS Bill using EBS Snapshots.
- We went through the steps to make an EBS Snapshot either Public or Private.
- Finally, we compared EBS Snapshots with AMIs.