Amazon EC2 Backup & Restore using AWS Backup

10 minute tutorial

Introduction

AWS Backup enables you to centralize and automate data protection across AWS services. AWS Backup offers a cost-effective, fully managed, policy-based service that simplifies data protection at scale. AWS Backup helps you support your regulatory compliance obligations and meet your business continuity goals. 

With just a few clicks in the AWS Backup console, you can create backup policies that automate backup schedules and retention management. With AWS Backup, you can create backup policies called backup plans. You can use these plans to define your backup requirements, such as how frequently to back up your data and how long to retain those backups. AWS Backup lets you apply backup plans to your AWS resources by simply tagging them. AWS Backup then automatically backs up your AWS resources according to the backup plan that you defined.

You can use AWS Backup to create on-demand backup jobs, or customize a backup plan to backup the supported resources. When using AWS Backup with Amazon Elastic Compute Cloud (Amazon EC2) instances, you can centralize your compliance and policy control for backups, increase security choices for your organization, and access instant enterprise level features and functionality. When you back up an EC2 instance, AWS Backup will protect all Amazon EBS volumes attached to the instance, and it will attach them to an AMI that stores all parameters from the original EC2 instance (excluding Elastic Inference Accelerator and user data script).

What you will learn

  • How to create an on-demand backup job of an Amazon EC2 instance
  • How to use a backup plan to backup Amazon EC2 resources - using a backup plan within AWS Backup lets you automate your backups on a schedule
  • How to add resources to an existing backup plan using tags

 AWS Experience

Intermediate

 Time to Complete

10 minutes

 Cost to Complete

Implementation

You will need the following resources or permissions to proceed with this tutorial:
  • An AWS account will be needed for this tutorial. For more information on using AWS Backup for the first time, view the AWS Backup documentation.
  • One or more Amazon EC2 instances. You can refer to the Amazon EC2 pricing page for more details. For AWS Backup pricing, refer to the AWS Backup pricing page
  • IAM roles used by AWS Backup to create a backup of the Amazon EC2 instance. 
    • If a subsequent role is not created, then the default IAM role can be used - AWSBackupDefaultRole.
In this tutorial, you learn how to create an on demand backup job of an Amazon EC2 instance. Then, you will use a backup plan to protect EC2 resources. Using a backup plan within AWS Backup lets you automate backups using tags. 
  • Step 1: Go to the AWS Backup console
    Go to AWS Backup in the AWS Management Console (2)
  • Step 2: Configure an on-demand AWS Backup job of an Amazon EC2 instance
    • 2.1 — Configure the services used with AWS Backup
      • On the navigation pane on the left side of the AWS Backup console, under My account, choose Settings.
      • On the Service opt-in page, select the Configure resources button.
    2.1 (A) To configure the services used with AWS Backup*
    • 2.1 — Configure the services used with AWS Backup (continued) 
      • On the Configure resources page, use the toggle switches to enable or disable the services used with AWS Backup. In this case, select EC2. Choose Confirm when your services are configured.
        • AWS resources that you're backing up should be in the Region you are using for this tutorial, and resources must all be in the same AWS Region (however, see step 3.2 for information on cross-Region copy). This tutorial uses the US East (N. Virginia) Region (us-east-1). 
    Configure resources - AWS Backup
    • 2.2 — Create an on-demand backup Job of an Amazon EC2 instance
      • Back in the AWS Backup console, under My account, select Dashboard on the left navigation pane. Then, select the Create on-demand backup button.
    step-2-2a-configure-on-demand-aws-backup-job-of-ebs-volume
    • 2.2 — Create an on-demand backup Job of an Amazon EC2 instance (continued)
      • On the Create on-demand backup page, choose the Resource type that you want to back up; for example, choose EC2 for Amazon EC2 instance.
      • Choose the Instance ID of the EC2 resource that you want to protect.
      • In the Backup window section, select Create backup now. This initiates a backup immediately and enables you to see your saved resource sooner on the Protected resources page.
      • In the Retention period section, select Days and type the number of days you want to retain the backups for. This example uses a Retention period of 7 days.
      • In the Backup vault section, select one of the pre-existing vaults and continue with step 2.2, or follow step 2.2.1 to create a new backup vault (which begins with selecting Create new Backup vault) before continuing with step 2.2. 
    AWS Backup - Create on-demand backup - Resource type EC2 - tutorial step 2.2
    • 2.2.1  — Create a backup vault
      • Instead of using the default backup vault that is automatically created for you on the AWS Backup console, you can create specific backup vaults to save and organize groups of backups in the same vault. 
      • On the Create on-demand backup page, choosing Create new Backup vault opens a new page to create a vault, and you are returned to the Create on-demand backup page after you are finished.
        • You can also go to the AWS Backup console in the navigation pane on the left and select Backup vaults and then Create backup vault to create a backup vault. 
      • Enter a name for your backup vault. You can name your vault to reflect what you will store in it, or to make it easier to search for the backups you need. For example, you could name it "webappBackups."
      • Select an AWS Key Management Service (KMS) key. You can use either a key that you already created, or select the default AWS Backup master key.
    step-2-2-1a-configure-on-demand-aws-backup-job-of-ebs-volume
    • 2.2.1 — Create a backup vault (continued)
      • Optionally, add tags that will help you search for and identify your backup vault. 
    step-2-2-1b-configure-on-demand-aws-backup-job-of-ebs-volume
    • 2.2 — Create a backup vault (continued)
      • Back on the Create on-demand backup page, after you have selected an existing backup vault or created a new one, choose the Default role for the IAM role, as shown in the following screenshot, or Choose an IAM role
        • Note: If the AWS Backup Default role is not present in your account, then one is created with the correct permissions.
      • Select the Create on-demand backup button. This takes you to the Jobs page, where you will see a list of jobs.
    step-2-2c-configure-on-demand-aws-backup-job-of-ebs-volume
    • 2.3 — Checking job details
      • In the Jobs panel under My account, ensure the Backup jobs tab is selected. 
      • Choose the Backup job ID for the resource that you chose to back up to see the details of that job.
      • After some time, the Status of the backup job will go from Created to Completed.
    Checking job details - AWS Backup - Amazon EC2 tutorial - step 2.3
  • Step 3: Configure an automatic AWS Backup job of an Amazon EC2 instance
    • 3.1 — Configure the services used with AWS Backup
      • On the navigation pane on the left side of the AWS Backup console, under My account, choose Settings.
      • On the Service opt-in page, select the Configure resources button.
    step-2-1a-configure-on-demand-aws-backup-job-of-ebs-volume
    • 3.1 — Configure the services used with AWS Backup (continued)
      • On the Configure resources page, use the toggle switches to enable or disable the services used with AWS Backup. Choose Confirm when your services are configured.
        • AWS resources that you're backing up should be in the Region you are using for this tutorial, and resources must all be in the same AWS Region (however, see step 3.2 for information on cross-Region copy). This tutorial uses the US East (N. Virginia) Region (us-east-1). 
    Configure resources - AWS Backup - Select Amazon EC2
    • 3.2  — Configure a backup plan for an Amazon EC2 instance
      • In the AWS Backup console, under My account, select Backup plans on the left rail, and then select the Create Backup plan button.
    step-3-2-configure-automatic-aws-backup-jobs-of-an-amazon-rds-database
    • 3.2 — Configure a backup plan for an Amazon EC2 instance (continued)
      • AWS Backup provides three ways to get started using the AWS Backup console:
        • Start from an existing plan: You can create a new backup plan based on the configurations in an existing plan. Be aware that backup plans created by AWS Backup are based on backup best practices and common backup policy configurations. When you select an existing backup plan to start from, the configurations from that backup plan are automatically populated for your new backup plan. You can then change any of these configurations according to your backup requirements.
        • Build a new plan from scratch: You can create a new backup plan by specifying each of the backup configuration details, as described in the next section. You can choose from the recommended default configurations.
        • Define a plan using JSON: You can modify the JSON expression of an existing backup plan or create a new expression.
      • Backup plan name - You must provide a unique backup plan name. If you try to create a backup plan that is identical to an existing plan, you get an AlreadyExistsException error.
    (update) Creating a backup plan in the AWS Backup console - Amazon EC2 Backup and restore using AWS Backup - step 3.2
    • 3.2 — Configure a backup plan for an Amazon EC2 instance (continued) 
      • Backup rule name - Backup plans are composed of one or more backup rules. Backup rule names are case sensitive. They must contain from 1 to 63 alphanumeric characters or hyphens.
      • In the Backup vault section, you can select the default vault or one of the pre-existing vaults. Backups created by a backup rule are organized in the backup vault that you specify in the backup rule. You can use backup vaults to set the AWS KMS encryption key that is used to encrypt backups in the backup vault and to control access to the backups in the backup vault. You can also add tags to backup vaults to help you organize them. If you don't want to use the default vault, you can create your own.
      • Create new Backup vault - Instead of using the default backup vault that is automatically created for you on the AWS Backup console, you can create specific backup vaults to save and organize groups of backups in the same vault. To create a new backup vault, refer to step 3.2.1.
      • In the Backup Frequency section, Choose Daily. The backup frequency determines how often a backup is created. You can choose a frequency of every 12 hours, daily, weekly, or monthly. When selecting weekly, you can specify which days of the week you want backups to be taken. When selecting monthly, you can choose a specific day of the month.
      • In the Backup window section, select backup window defaults, which initiates the backup job at 5 AM UTC (Coordinated Universal Time) and lasts 8 hours. If you would like to customize the backup frequency, refer to the documentation for more information.
      • In the Transition to cold storage section, keep the default - Never
      • In the Retention period section, select Days and type "7" (or you can put in any number of days desired). 
    Backup rule configuration - Amazon EC2 Backup and Restore using AWS Backup - 3.2 (1)
    • 3.2 — Configure a backup plan for an Amazon EC2 instance (continued) 
      • In the Copy to destination section, leave it as the default, since this tutorial covers backups within the same AWS Region. As part of your backup plan, you can optionally create a backup copy in another AWS Region. Using AWS Backup, you can copy backups to multiple AWS Regions on-demand, or automatically as part of a scheduled backup plan. Cross-region replication is particularly valuable if you have business continuity or compliance requirements to store backups a minimum distance away from your production data. When you define a backup copy, you configure the following options:
        • Destination Region: The destination Region for the backup copy
        • (Advanced Settings) Backup Vault: The destination backup vault for the copy.
        • (Advanced Settings) IAM Role: The IAM role that AWS Backup uses when creating the copy. The role must also have AWS Backup listed as a trusted entity, which enables AWS Backup to assume the role. If you choose Default and the AWS Backup default role is not present in your account, a role is created for you with the correct permissions.
        • (Advanced Settings) Lifecycle: Specifies when to expire (delete) the copy.
        • Note: Cross-region copy incurs additional data transfer costs. You can refer to the AWS Backup pricing page.
      • Tags added to recovery points: The tags that you list here are automatically added to backups when they are created.
      • Advanced Backup Settings: Enables application consistent backups for third-party applications that are running on Amazon EC2 instances. Currently, AWS Backup supports Windows VSS backups. This is only applicable for Windows EC2 Instances running SQL Server or Exchange Databases. You can refer to the documentation for more details.
      • Then, select the Create Plan button. Once the plan is created, tags and resources can be added to the backup plan.
    Confuring a backup plan in the AWS Backup console   - copy to destination and advanced backup settings
    • 3.2.1 — Create a backup vault
      • In the AWS Backup console, in the left navigation pane under My account, select Backup vaults.
      • Select Create backup vault.
      • Enter a name for your backup vault. You can name your vault to reflect what you will store in it, or to make it easier to search for the backups you need. For example, you could name it "WebappBackups."
      • Select an AWS KMS key. You can use either a key that you already created, or select the default AWS Backup master key.
    step-3-2-1a-configure-automatic-aws-backup-job-of-ebs-volume
    • 3.2.1 — Create a backup vault (continued)
      • Optionally, add tags that will help you search for and identify your backup vault. 
    step-2-2-1b-configure-on-demand-aws-backup-job-of-ebs-volume
    • 3.3 — Assign resources to the backup plan
      • When you assign a resource to a backup plan, that resource is backed up automatically according to the backup plan. The backups for that resource are managed according to the backup plan. You can assign resources using tags or resource IDs. Using tags to assign resources is a simple and scalable way to back up multiple resources.
      • Select the created backup plan and select the Assign resources button. 
    Assign resources to the backup plan - Amazon EC2 Backup and Restore using AWS Backup (1)
    • 3.3 — Assign resources to the backup plan (continued)
      • Resource assignment name: Provide a resource assignment name.
      • IAM Role: When creating a tag-based backup plan, if you choose a role other than Default role, make sure that it has the necessary permissions to back up all tagged resources. AWS Backup tries to process all resources with the selected tags. If it encounters a resource that it doesn't have permission to access, the backup plan fails.
      • Assign by: You can select Tags or Resource ID. For a tags-based resource assignment, provide the key-value pair of the Amazon EC2 instance. 
      • Select Assign resources. The backup plan will then have the resources assigned to it.
    Assign resources to the backup plan - Amazon EC2 backup and restore using AWS Backup - continued
    • 3.3 — Assign resources to the backup plan (continued)
      • Navigate to the AWS Backup console and select Jobs in the left navigation pane. Once there, you will be able to see your Backup jobs.
      • A backup, or recovery point, represents the content of a resource, such as an Amazon EC2 instance or Amazon RDS database, at a specified time. Recovery point is a term that refers generally to the different backups in AWS services, such as Amazon EBS snapshots and Amazon RDS backups. In AWS Backup, recovery points are saved in backup vaults, which you can organize according to your business needs. Each recovery point has a unique ID. 
    Navigate to the AWS Backup console and select Jobs in the left navigation pane. Once there, you will be able to see your
  • Step 4: Restore an Amazon EC2 instance using AWS Backup
    • 4.1 — Restoring your Amazon EC2 instance using AWS Backup
      • Navigate to the backup vault that was selected in the backup plan and select the latest completed backup. To restore the EC2 instance, click on the recovery point ARN and select the Restore button. 
    To restore the EC2 instance, click on the recovery point ARN and select the Restore button. (1)
    • 4.1 — Restoring your Amazon EC2 instance (continued)
      • The restore of the ARN will bring you to a Restore backup screen that will have the configurations for the EC2 instance using the backed up AMI and all the attached EBS volumes.
      • In the Network settings pane, accept the defaults or specify the options for the Instance type, Virtual Private Cloud (VPC), Subnet, Security groups, and Instance IAM Role settings.
      • This example proceeds with no IAM role. The IAM role can be applied to the EC2 instance after the restore process is completed. 
        • To successfully do a restore with the original instance profile, you must edit the restore policy. If you apply an instance profile during the restore, you have to update the operator role and add the PassRole permissions of the underlying instance profile role to Amazon EC2. The default service role created by AWS Backup manages creating and restoring backups. It has two managed policies, AWSBackupServiceRolePolicyForBackup and AWSBackupServiceRolePolicyForRestores. It also allows “Action”: “iam:PassRole” to launch EC2 instances as part of a restore. 
    Restore backup screen that will have the configurations for the EC2 instance using the backed up AMI and attached EBS volumes (1)
    • 4.1 — Restoring your Amazon EC2 instance (continued)
      • In the Restore role pane, accept the Default role or Choose an IAM role to specify the IAM role that AWS Backup will assume for this restore. 
      • In the Advanced settings pane, accept the defaults or specify the options for Shutdown behavior, Enable termination protection, Placement group, T2/T3 Unlimited, Tenancy, and User data settings. This section is used to customize shutdown and hibernation behavior, termination protection, placement groups, tenancy, and other advanced settings. 
      • AWS Backup will use the SSH key pair used at time of backup to automatically perform your restore.
      • After specifying all of your settings, choose Restore backup. The Restore jobs pane will appear, and a message at the top of the page will provide information about the restore job.
    (1) In the Restore role pane, accept the Default role or Choose an IAM role to specify the IAM role that AWS Backup will assume for this restore.
    • 4.2 — Checking for your restored Amazon EC2 instance
    (updated) Checking for your restored Amazon EC2 instance (Amazon EC2 Backup and restore using AWS Backup)
    • 4.2 — Checking for your restored Amazon EC2 instance (continued)
      • Once the job status appears as completed, navigate to the Amazon EC2 console and select Instances on the left hand pane to see the restored EC2 instance. The EC2 instance is restored using the backup of the AMI and the attached EBS volume. 
    (updated) Navigate to the Amazon EC2 console, select Instances on the left hand pane to see the restored EC2 instance
  • Step 5: Next steps

    You can now connect to the public IP address if you restored your Amazon EC2 instance using SSH.

  • Step 6: Clean up

    In the following steps, you clean up the resources you created in this tutorial. It is a best practice to delete instances and resources that you are no longer using so that you are not continually charged for them.

    • 6.1 — Delete the Amazon EC2 instance
      • Open the Amazon EC2 console
      • In the navigation pane on the left, choose Instance under Instances.
      • Select the restored EC2 instance, and choose Instance state, then Terminate instance.
      • Choose Terminate when prompted for confirmation.
    • 6.2 — Delete the AWS Backup recovery point
      • Open the AWS Backup console and navigate to the vault where the recovery point is stored.
      • Select the recovery point, then select Delete.
    Note: This process can take several seconds to complete. 
Additional resources: Working with Amazon EC2 and AWS Backup

Was this module helpful?

Thank you
Please let us know what you liked.
Close
Sorry to disappoint you
Is something out-of-date, confusing or inaccurate? Please help us improve this tutorial by providing feedback.
Close

Congratulations!

You have created a backup of an Amazon EC2 instance and performed a restore using AWS Backup!