How to backup/restore EC2 instances using AWS Backup

Andrei Maksimov
Andrei Maksimov

One of the most common questions I’m facing is, “How can I backup my EC2 instance?”. On Jan 16, 2019, AWS released their native service, allowing you to solve that particular problem quickly. In this article, I’ll cover on-demand and scheduled backup configuration for your EC2 instance and recovery process using AWS Backup.

What is AWS Backup

AWS Backup is a fully managed backup service that makes it easy to centralize and automate data backup across AWS services in the cloud and on-premises.

Currently, AWS Backup allows you to backup the following AWS services:

All you need to to to set up a backup is:

  • Create a backup plan
  • Mark AWS resources with the tag
  • Enjoy the result

Let’s dirty our hands and configure AWS Backup to backup our AWS resources.

Creating a backup plan

The backup plan is nothing more than a configuration, which allows you to configure a backup strategy for your AWS resources.

To configure a Backup plan, walk into your AWS Backup console and click Create Backup plan button.

1. How to backup and restore EC2 instances using AWS Backup - Welcome page

You’ll come to the wizard, which allows you to simplify plan configuration.

You can choose a predefined configuration from the template or create it from scratch.

2. How to backup and restore EC2 instances using AWS Backup - Create Backup plan - Step 1

We’ll build a new plan for this article, so choose the appropriate item from the menu and let’s get started.

First, you need to provide a backup name:

3. How to backup and restore EC2 instances using AWS Backup - Create Backup plan - Name

Next, you need to configure Backup rules, which control backup frequency, backup window, transition to the cold storage for at least 90 days storing, backup retention period, and additional destination (if you’re interested in disaster recovery).

4. How to backup and restore EC2 instances using AWS Backup - Create Backup plan - Backup rule configuration

As you can see from the screenshot, I have configured the following options:

  • The backup name is set up to Daily-Backup
  • The backup vault is set to Default; the vault is the special location where your backups are stored; the Default vault is not encrypted, so if you need to encrypt your backups, create a new vault to set up a KMS encryption
  • The backup frequency is set up to Daily; you may Hourly, Weekly, Monthly, or set up a custom CRON expression (here’s more information about CRON jobs)
  • Enable continuous backups is not selected as soon as I’m not using the RDS service
  • The backup window is set to default as I’m fine with backups happening at 5 AM. You may customize this by choosing another option
  • Transition to the cold storage is set to Never as I’m not planning to store backups longer than 90 days (this is the minimum retention time interval for storing your backups)
  • The retention period is set to 35 Days; other available options are Always (do not delete backups), Weeks, Months, and Years
  • Copy to destination is not set as soon as I do not need to store my backups in another AWS Region for disaster recovery (DR)
  • Tags added to recovery points – set them up if you’d like to have the ability to see backup costs at your billing report associated with this Backup plan separately.

If you have Windows applications, you may optionally choose Windows VSS in Advanced backup settings.

5. How to backup and restore EC2 instances using AWS Backup - Create Backup plan - Windows VSS

Click Create plan button.

Choosing resources to backup

As soon as your Backup plan is configured, you’ll be transferred to its configuration window.

6. How to backup and restore EC2 instances using AWS Backup - Backup plan configuration

Let’s start adding resources to the backup.

You can do it Resource assignments section – press the Assign resources button.

7. How to backup and restore EC2 instances using AWS Backup - Backup plan configuration - Assign resources

There are two possible ways to choose resources to backup:

  • AWS resources marked by specific tag
  • Specific AWS resources specified by ID

I found it more helpful to proceed with the first option.

In that case, you must mark supported AWS resources with a specific Tag to enable backup or remove tag to disable backup operation.

8. How to backup and restore EC2 instances using AWS Backup - Backup plan configuration - Assign resources by Tag

In my example, I’ll be using the following tag: Backup = true.

Set up the Resource assignment name and press the Assign resources button.

That’s it. Super simple. The backup of tagged resources will appear in the Default vault after the next backup operation.

On-demand backup of EC2 instance

Here’s a backup-demo instance, configured (has the tag Backup=true) for automatic backups:

10. How to backup and restore EC2 instances using AWS Backup - Backup plan configuration - On-demand backup - Demo instance

I will not wait for the next backup window and show you how to create an on-demand backup operation for your EC2 instance.

Now, at the AWS Backup service, go to the Dashboard and click Create on-demand backup button.

9. How to backup and restore EC2 instances using AWS Backup - Backup plan configuration - On-demand backup

Change the following configurations:

  • Resource typeEC2
  • Instance ID – pickup your instance
  • Backup windowCreate backup now
  • Retention period – Set your retention period (I’ll choose 1 day for this article)
11. How to backup and restore EC2 instances using AWS Backup - Backup plan configuration - On-demand backup - Create on-demand backup EC2 instance

The rest of the options might be unchanged.

Click Create an on-demand backup.

12. How to backup and restore EC2 instances using AWS Backup - Backup plan configuration - On-demand backup - Create on-demand backup EC2 instance - Progress

Depending on your instance, disk size backup might take minutes to several hours.

Restoring the EC2 instance from the backup

As soon as the backup of your EC2 instance is completed, you may go to your Backup vault and restore it.

To do that, select the backup you’re interested in and in the Actions menu, click Restore.

13. How to backup and restore EC2 instances using AWS Backup - Backup plan configuration - On-demand backup - Restore backup of the EC2 instance

The Restore backup wizard is similar to the Launch instance wizard. You must choose the same parameters like instance type, VPC, subnets, security groups, etc.

14. How to backup and restore EC2 instances using AWS Backup - Backup plan configuration - On-demand backup - Restore backup of the EC2 instance - Wizard

When you set up the required parameters for your instance, click the Restore backup button.

Summary

In this article, we described the AWS Backup service, the configuration of automatic backups of your AWS resources, and the processes of on-demand EC2 backup and restore. You can use AWS Backup reporting to track all your EC2 automated backups.

We hope that the article was helpful for you. If so, please, help us to spread it to the world!

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Want to be an author of another post?

We’re looking for skilled technical authors for our blog!

Leave a comment

If you’d like to ask a question about the code or piece of configuration, feel free to use https://codeshare.io/ or a similar tool as Facebook comments are breaking code formatting.