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

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](https://dev-to-uploads.s3.amazonaws.com/i/bcgcoidjfpmhx72zus1i.png)

**1. Backup rule**
The rule says daily backup and the backup will expire after one day
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xzdeui8inakrfp879nnf.png)

**2. Resource assignments**
- It can base on Tag or Resource ID
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/kyss8riia29mz6z1p2jp.png)

- This post introduces resource on Tag
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/md94yu5wh37xotzbdh72.png)

###Using AWS CDK (Cloud Development Kit) to create the backup plan
**1. To get familiar with CDK, go to [Your first AWS CDK app](https://docs.aws.amazon.com/cdk/latest/guide/hello_world.html)**

**2. Create cdk-aws-backup project**
Enter fullscreen mode Exit fullscreen mode

mkdir cdk-aws-backup
cd cdk-aws-backup
cdk init -l python


**3. Create stacks through code**
Source: https://github.com/vumdao/cdk-aws-backup
- Stacks: https://github.com/vumdao/cdk-aws-backup/blob/master/aws_backup/aws_backup_stack.py
- app: https://github.com/vumdao/cdk-aws-backup/blob/master/app.py

**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**
Enter fullscreen mode Exit fullscreen mode

cdk deploy


**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
Enter fullscreen mode Exit fullscreen mode

Top comments (0)