How to backup/restore EC2 instances using AWS Backup

Andrei Maksimov

Andrei Maksimov

0
(0)

One of the most common questions I’m facing is “How I can backup my EC2 instance?”. On Jan 16, 2019, AWS released their native service, which allows you to solve that particular problem with ease. 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 the backup of data across AWS services in the cloud as well as 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 make our hands dirty and configure AWS Backup to backup our AWS resources.

Creating a backup plan

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 chose 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

For the purpose of this article we’ll build a new plan, so chose 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 controls 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:

  • Backup name is set up to Daily-Backup
  • 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
  • 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
  • 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)
  • 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 an ability to see backup costs at your billing report associated with this Backup plan separately

If you have Windows applications you may optionally chose 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 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 backup.

You can do it Resource assignments section. Press 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 chose resources to backup:

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

Personally I found it more useful to proceed with the first option.

In that case all you have to do is to mark supported AWS resource with 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 Tag Backup = true.

Set up Resource assignment name and press Assign resources button.

That’s it. Super simple. 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 how to create on-demand backup operation for your EC2 instance.

Now, at 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 own retention period (I’ll choose 1 day for the purpose of 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 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 you instance disk size backup might take from a couple of minutes to a several hours.

Restoring 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 need to 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

As soon as you set up required parameters for your instance, click Restore backup button.

Summary

In this article we described the AWS Backup service, configuration of automatic backups of your AWS resources, and the processes of on-demand EC2 backup and restore.

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

How useful was this post?

Click on a star to rate it!

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Top rated Udemy Courses to improve you career

Subscribe to our updates

Like this article?

Share on facebook
Share on Facebook
Share on twitter
Share on Twitter
Share on linkedin
Share on Linkdin
Share on pinterest
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.