Table of contents
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.
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.
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:
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).
As you can see from the screenshot, I have configured the following options:
- Backup name is set up to
- Backup vault is set to
Default; the vault is the special location, where your backups are stored; the
Defaultvault 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
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
Neveras 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
35Days; other available options are
Always(do not delete backups),
- 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.
Click Create plan button.
Choosing resources to backup
As soon as your Backup plan configured, you’ll be transferred to its configuration window.
Let’s start adding resources to backup.
You can do it Resource assignments section. Press Assign resources button.
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.
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:
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.
Change the following configurations:
- Resource type –
- Instance ID – pickup your instance
- Backup window –
Create backup now
- Retention period – Set your own retention period (I’ll choose 1 day for the purpose of this article)
The rest of the options might be unchanged.
Click Create on-demand backup.
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.
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.
As soon as you set up required parameters for your instance, click Restore backup button.
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!