How to create and manage Amazon EBS snapshots via AWS CLI – TechTarget

While Amazon EC2 provides the ability to launch a variety of virtual servers, there is also the need to deploy data storage for each virtual server.

Amazon Elastic Block Storage (EBS) volumes are virtual storage devices in the cloud that get attached to EC2 instances and provide internal storage for essential areas in any application, such as OS files, source code, libraries and configuration files. Given the critical nature of this data, enterprises need a reliable way to create and manage backups of EBS volumes.

Learn how EBS snapshots can help with disaster recovery, as well as how to create and manage them through the AWS Command Line Interface.

EBS snapshots are a point-in-time backup of an EBS volume. With EBS snapshots, users can control how data in an EBS volume is backed up, stored, managed and recovered. Developers can trigger the creation of an EBS snapshot using the AWS CLI or SDK, or through the EC2 console. Some core features of EBS snapshots include the following:

EBS snapshots are a better fit for the creation of regular backups of EBS volumes. For a solid disaster recovery strategy, users should create snapshots routinely and copy them to other AWS Regions and AWS accounts. EBS snapshots can also be transitioned to cold storage, which is an option to consider to significantly reduce storage costs.

EBS snapshots cost $0.05 per GB, per month, for the standard tier. The cost to create and keep an Amazon Machine Image depends solely on the EBS snapshots that are essential to that AMI. A 100 GB EBS snapshot or AMI would cost $5 per month. Subsequent snapshots of a particular EBS volume are charged based only on the blocks that have changed since the previous snapshot.

To reduce costs, users can transition snapshots to the Archive tier, which costs $0.0125 per GB, per month. In the Archive tier, the same 100 GB snapshot would then cost $1.25 per month. Data retrieval from the Archive tier is billed at $0.03 per GB. Be aware that there's a minimum 90-day retention period.

When users create an EBS snapshot, they can use it to configure an EC2 AMI. An AMI supplies a storage image, which a new EC2 instance requires at launch.

An active EC2 instance can also create an AMI. The EC2 service first creates one or more EBS snapshots, which are then automatically used for the new AMI. The number of snapshots produced depends on how many EBS volumes are attached to the source EC2 instance. The EC2 service creates one EBS snapshot per attached EBS volume.

EC2 instances can be launched only from an existing AMI and not directly from an EBS snapshot. If an EBS snapshot is used as the source data to launch new EC2 instances, it must first be used to create an AMI. Then, the AMI will be the input when launching new EC2 instances.

Since AMIs are a way to manage the starting point of new EC2 instances, there is no need to create AMIs as frequently as EBS snapshots. Also, AWS recommends maintaining cross-region and cross-account copies of AMIs for disaster recovery purposes, as well as enabling encryption when creating EBS volumes and snapshots.

It's convenient to launch and manage EBS snapshots through the AWS CLI. The create-snapshot command provides a way to quickly start snapshot creation. A basic example of this CLI command looks like the following example.

This command returns, among other data, the SnapshotId value of the recently created snapshot, as well as its creation state, the value of which will be Pending right after calling this command.

The describe-snapshots command in the following example offers a way to list and filter snapshots in your account.

This command also offers a useful filters parameter to narrow the list of returned EBS snapshots.

As with any AWS CLI command, it's important to define region and profile parameters, or set them through the AWS_DEFAULT_REGION and AWS_PROFILE environment variables, respectively. The examples provided show basic scenarios. Keep in mind that the CLI offers additional parameters that deliver more options.

See more here:
How to create and manage Amazon EBS snapshots via AWS CLI - TechTarget

Related Posts

Comments are closed.