How to Backup AWS EC2 Instances with EBS Snapshots

choubertsprojects

VPN offers!

1. NordVPN

2. Surfshark

3. ExpressVPN

This guide will take you through the process of backing up your AWS EC2 instances with EBS snapshots. It is important to backup your data before making any drastic changes or upgrades so that if something goes wrong, all of your instance’s data can be recovered quickly and easily.

The “aws snapshots” is a new feature that has been added to the AWS EC2 Instances. This will allow you to backup your instances without having to shut them down.

How to Backup AWS EC2 Instances with EBS Snapshots

[*]

EC2 instances from Amazon Web Services (AWS) are a handy method to execute workloads on Virtual Machines (VM). But what if the storage to which they’re connected fails or gets corrupt? It’s time to start talking about AWS EC2 backups.

When backing up an EC2 instance, you’ll be using EBS volumes, especially EBS snapshots. EBS is used by EC2 to store all volumes, and taking an EBS snapshot is an excellent approach to backup your data.

In this video, you’ll learn how to use the AWS Management Console and the AWS Command Line Interface to make EBS snapshots (AWS CLI).

How to Use PowerShell to Manage and Automate AWS EC2 Snapshots

Check out Veeam Backup for AWS if you want to handle EC2 backups and EBS snapshots with ease. Veeam controls replication, intelligently monitors for changing blocks, and offers a public API in addition to making EBS snapshots.

Prerequisites

This page will serve as a guide. You’ll need the following items if you want to follow along step-by-step:

This article does not cover IAM policy development or AWS Application Programming Interface (API) permissions. When authorizing accounts to conduct activities, always follow the concept of least privilege.

  • On your local system, the AWS CLI was installed and authorized with your IAM user.

Using the AWS Management Console to create an EBS Snapshot

EBS snapshots may be created in a variety of methods. Let’s get started using the AWS administration panel to create snapshots.

Storage expenses may apply to EBS Snapshots. Refer to the AWS Documentation for further information on how EBS billing is determined.

Accessing the EC2 Console

To begin, go to:

  1. Sign in to your AWS account using your AWS (root) or IAM account credentials in the AWS Management Console.

2. In the top left-hand corner of your screen, click Services.

The services drop-down menu in the AWS Management Console.The services drop-down menu in the AWS Management Console.

3. From the Services drop-down box, choose EC2. As illustrated below, the EC2 option is found under the Compute category. This will take you to the Amazon EC2 console.

AWS Management Console with EC2 option and services drop-down menu.AWS Management Console with EC2 option and services drop-down menu.

You should now be on the dashboard for Resources. The Resources dashboard gives you a rapid overview of the EC2-related resources available in your chosen location. The Resources dashboard for this lesson reveals the following for the signed-in user in the US East (N. Virginia) area, as seen in the picture below.

The EC2 Console Resources Dashboard displays existing resources.The EC2 Console Resources Dashboard displays existing resources.

Using the EC2 Console to create an EBS Snapshot

It’s time to generate an EBS Snapshot once you’ve browsed to the EC2 interface and selected your desired region (AWS EC2 backup). To complete this mission, you must:

  1. From the navigation pane on the left-hand side of the screen, choose Snapshots under Elastic Block Store.

Snapshots option in the EC2 Console.Snapshots option in the EC2 Console.

2. From the top of your screen, choose Create Snapshot. When you choose Create Snapshot, you’ll be taken to a menu that needs some further information.

The Create Snapshot option in the EC2 Console's Snapshots section.The Create Snapshot option in the EC2 Console’s Snapshots section.

3. In the Select resource type section on the Create Snapshot page, select Volume as the resource type. When you choose Volume as the resource type, AWS will take a snapshot of a single EBS volume, not all of the volumes associated to the EC2 instance.

Create a Snapshot menu with options for Volume and Instance.Create a Snapshot menu with options for Volume and Instance.

4. From the dropdown menu, pick the Volume ID of the EBS Volume to snapshot. Each EBS Volume is given a unique identification called a Volume ID. The Volume ID vol-0b4f056a0b709240a for this lesson is chosen in the following snapshot.

Create a Snapshot menu with the Volume field filled.Create a Snapshot menu with the Volume field filled.

5. In the Description section, provide a description for your EBS Snapshot. The Description field may contain up to 255 characters and is optional.

This description will appear as a property on the EBS snapshot later. The explanation for this lesson will be based on Volume Snapshot for ATA Blog.

The completed Description form is shown in the Create Snapshot menu.The completed Description form is shown in the Create Snapshot menu.

6. Finally, you may use optional key/value combinations to tag your EBS snapshot. Within AWS, tags are a great method to manage and organize your resources. This lesson will utilize tags to demonstrate a typical server use case.

Name, Owner, Environment, and Purpose are all popular tags.

Create a Snapshot menu with the Tag field filled.Create a Snapshot menu with the Tag field filled.

7. To generate an EBS snapshot, click the Create Snapshot button.

The Create Snapshot menu displays the Create Snapshot option. The Create Snapshot menu displays the Create Snapshot option.

The Encrypted field was not covered in this lesson. EBS snapshots generated from unprotected EBS Volumes are not able to be encrypted during the creation chevalier. To encrypt an EBS Snapshot obtained from an unencrypted EBS Volume, first finish the unencrypted EBS Snapshot, duplicate it, then apply the necessary encryption. Snapshots taken from encrypted volumes are encrypted automatically.

8. When everything is finished, the EC2 console displays the following success message. Select Close to delete the message.

Message of accomplishment Request for a SnapshotMessage of accomplishment Request for a Snapshot

The EBS snapshot should now be shown in the console with a pending status. This state will be maintained until all changed EBS volume blocks have been copied to Amazon S3.

The EC2 Console's Snapshots section displays pending snapshots.The EC2 Console’s Snapshots section displays pending snapshots.

Because first EBS snapshots are complete backups, they take longer to make than later incremental backups. If the snapshot seems to be taking longer than it should, use the refresh icon in the top right-hand corner of your screen to update the status.

When the snapshot is finished, you’ll notice a completed status as shown below.

The finished snapshot in the EC2 Console's Snapshots section.The finished snapshot in the EC2 Console’s Snapshots section.

You’ve successfully made an AWS EC2 backup!

Using the AWS CLI to create an EBS Snapshot

You produced an EBS snapshot using AWS’ web-based interface in the previous section, but it isn’t the only approach! You may also backup an EC2 instance by using the AWS CLI to create a snapshot.

If you have the AWS CLI installed and authenticated to your account, you may make your snapshot using it:

  1. On your Windows PC, open a command prompt or a PowerShell console.

2. Use the —query argument in the aws ec2 describe-volumes command to get a list of instances and volume IDs. Make a mental note of the Volume ID you wish to capture.

—query ‘Volumes[*]’ aws ec2 describe-volumes Attachments[]. {VolumeID:VolumeId,InstanceID:InstanceId}’ —text output

3. Enter the following arguments into the command aws ec2 create-snapshot:

  • volume-id – the EBS Volume ID that you are trying to backup.
  • description – the description you’d want to use for the backup
  • tag-specifications – the tags you want to apply to your backup

The next command generates a snapshot of the volume specified to the right with the —volume-id argument, along with the description Volume Snapshot for ATA Blog through the AWS CLI and two tags: Name: FileServer01 and Purpose: Enterprise File Storage.

# Be sure to insert your volume ID aws ec2 create-snapshot –volume-id <your volume ID> –description ‘Volume Snapshot for ATA Blog via the AWS CLI’ –tag-specifications ‘ResourceType=snapshot,Tags=[{Key=Name,Value=FileServer01},{Key=Purpose,Value=Enterprise File Storage}]’

Successful command output from the AWS CLI. Successful command output from the AWS CLI.

AWS lets you customize the default output format of AWS CLI commands to suit your needs. JSON, YAML, YAML-Stream, Text, and Table are among the output formats available. Your command’s output is determined by the settings of your AWS CLI and may change from the result seen above.

4. Use the aws ec2 describe-snapshots command to examine the status of the snapshot by passing the snapshot’s ID to the —snapshot-id option. From the SnapshotID property returned in step 2, get the snapshot ID.

If you don’t know the snapshot ID, use aws ec2 describe-snapshots —owner self to search all of your snapshots.

# Be sure to insert your snapshot ID aws ec2 describe-snapshots –snapshot-id <your snapshot ID>

As illustrated below, the describe-snapshots command should eventually return a Progress of 100% and a State of finished.

The finished EBS Snapshot as seen via the AWS CLI.The finished EBS Snapshot as seen via the AWS CLI.

Excellent job! You just used the AWS CLI to generate an EBS Snapshot programmatically!

Steps to Follow

You learned how to use the web-based AWS interface and the programmatic AWS CLI to generate backups of Amazon EC2 instances using EBS snapshots in this lesson.

To prevent getting charged, make sure you remove the snapshot you made in this guide after you’ve finished testing it.

Try restoring an EC2 instance if you want to go any farther.

The “aws ebs snapshot pricing” is a must have for anyone who wants to backup their AWS instances with EBS snapshots. It includes the price of the snapshot, as well as how many snapshots are included in the backup.

Related Tags

  • aws ebs automated backup
  • aws ec2 backup
  • aws backup ebs
  • aws snapshot vs backup
  • aws instance snapshot vs volume snapshot