DEV Community

Cover image for Create AWS Backup Plan
🚀 Vu Dao 🚀
🚀 Vu Dao 🚀

Posted on

Create AWS Backup Plan

Alt Text

  • AWS Backup is a fully managed backup service that makes it easy to centralize and automate the backup of data across AWS services.

  • Using AWS Backup, you can centrally configure backup policies and monitor backup activity for AWS resources, such as Amazon EBS volumes, Amazon EC2 instances, Amazon RDS databases, Amazon DynamoDB tables, Amazon EFS file systems, Amazon FSx file systems, and AWS Storage Gateway volumes.

  • This article gives an example of how to create backup plans for volumes (root and mount) of multiple instances using AWS CDK based on Tags. For example,

Tags
vc:aws-volume:kind - ebs-ddb
Enter fullscreen mode Exit fullscreen mode

Any volumes with this tag within a region will be included in the backup plans resource assignment.

Aws-Backup plan includes two mains thing: Backup rules and Resource assignments

Alt Text

1. Backup rule
The rule says daily backup and the backup will expire after one day
Alt Text

2. Resource assignments

  • It can base on Tag or Resource ID
    Alt Text

  • This post introduces resource on Tag
    Alt Text

Using AWS CDK (Cloud Development Kit) to create the backup plan

1. To get familiar with CDK, go to Your first AWS CDK app

2. Create cdk-aws-backup project

mkdir cdk-aws-backup
cd cdk-aws-backup
cdk init -l python
Enter fullscreen mode Exit fullscreen mode

3. Create stacks through code
Source: https://github.com/vumdao/cdk-aws-backup

4. Tag the resources using bash script
Source: https://github.com/vumdao/cdk-aws-backup/blob/master/tag_volume.sh

  • The script will loop all instances with name *-ddb-instance and then tag volumes of the instance as Key=$region:aws-volume:kind,Value=ebs-storage

5. Run cdk deploy to create stack

cdk deploy
Enter fullscreen mode Exit fullscreen mode

Note: This post does not show the output of running cdk deploy because it contain AWS account information, leave comments here if there's any issue or need support

Top comments (0)