Table of contents
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.
How to Install Ansible in AWS and Manage servers Via Ansible
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.
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.
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:
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).
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
Neveras 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
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 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.
Click Create plan button.
Choosing resources to backup
As soon as your Backup plan is configured, you’ll be transferred to its configuration window.
Let’s start adding resources to the backup.
You can do it Resource assignments section – press the Assign resources button.
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.
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:
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.
Change the following configurations:
- Resource type –
- Instance ID – pickup your instance
- Backup window –
Create backup now
- Retention period – Set your retention period (I’ll choose 1 day for this article)
The rest of the options might be unchanged.
Click Create an on-demand backup.
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.
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.
When you set up the required parameters for your instance, click the Restore backup button.
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!
I’m a passionate Cloud Infrastructure Architect with more than 15 years of experience in IT.
Any of my posts represent my personal experience and opinion about the topic.