Bobcares

Manage AWS Backup settings using AWS CloudFormation templates

PDF Header PDF Footer

Want to manage AWS Backup settings using AWS CloudFormation templates? We can help you.

As a part of our AWS Support Services, we often receive similar requests from our AWS customers.

Today, let’s see the steps followed by our Support Techs to help our customers.

How to manage AWS Backup settings using AWS CloudFormation templates?

You can create CloudFormation templates using the supported AWS Backup resource types.

Example CloudFormation templates that you can create for AWS Backup include:

  • Firstly, a template to create a backup plan and assign a resource to the backup plan.
  • Secondly, a template to create a backup plan, create a backup vault, and assign a resource to the backup plan.

Today, let us see the examples provided by our Support techs.

 

Template to create a backup plan and assign a resource to the backup plan

The following example CloudFormation template in YAML does the following:

  • Firstly, creates a backup plan named BackupPlanWithThinBackups.
  • Then, sets backups to store in the vault named Default.
  • Next, creates a backup rule named RuleForDailyBackups that’s schedule to run a daily backup at 11:25AM.
  • Next, enables Windows VSS.
  • Then, sets the lifecycle of the backups to delete seven days after they’re create.
  • Next, sets the CopyAction to copy backups to the us-west-2 AWS Region for disaster recovery.
  • Then, Uses the AWS Identity and Access Management (IAM) role named AWSBackupDefaultServiceRole to run the backup job.
  • Finally, assigns the backup plan to all resources that are tagged with the key backupplan and the value dsi-sandbox-daily.
AWSTemplateFormatVersion: 2010-09-09
Description: >-
Backup Plan template to back up all resources tagged with backupplan=dsi-sandbox-daily at 11:25am
UTC.
Resources:
BackupPlanWithThinBackups:
Type: "AWS::Backup::BackupPlan"
Properties:
BackupPlan:
BackupPlanName: "BackupPlanWithThinBackups"
AdvancedBackupSettings:
-
ResourceType: EC2
BackupOptions:
WindowsVSS: enabled
BackupPlanRule:
-
RuleName: "RuleForDailyBackups"
TargetBackupVault: Default
ScheduleExpression: "cron(25 11 ? * * *)"
Lifecycle:
DeleteAfterDays: 7
CopyActions:
-
DestinationBackupVaultArn: arn:aws:backup:us-west-2:111222333444:backup-vault:Default
Lifecycle:
DeleteAfterDays: 14
TagBasedBackupSelection:
Type: "AWS::Backup::BackupSelection"
Properties:
BackupSelection:
SelectionName: "TagBasedBackupSelection"
IamRoleArn: !Sub "arn:aws:iam::111222333444:role/service-role/AWSBackupDefaultServiceRole"
ListOfTags:
-
ConditionType: "STRINGEQUALS"
ConditionKey: "backupplan"
ConditionValue: "dsi-sandbox-daily"
BackupPlanId: !Ref BackupPlanWithThinBackups
DependsOn: BackupPlanWithThinBackups

 

Template to create a backup plan, create a backup vault, and assign a resource to the backup plan

The following example CloudFormation template in YAML does the following:

  •  Firstly, creates a backup vault named Default.
  •  Then, creates a backup plan named BackupPlanWithThinBackups.
  •  Next, sets backups to store in the vault BackupVaultWithThinBackups.
  •  Then, creates a backup rule named RuleForDailyBackups that’s scheduled to run a daily backup. These backups are set to delete seven days after they’re created.
  •  Next, enables Windows VSS.
  • Then, sets the CopyAction to copy backups to the us-west-2 AWS Region for disaster recovery. These backups are set to delete 14 days after they’re created.
  • Then, creates a backup rule named RuleForWeeklyBackups that’s scheduled to run a weekly backup every Monday at 11:00 AM.
  • Then, these backups are set to delete 28 days after they’re create.
  • Next, creates a backup rule named RuleForMonthlyBackups that’s scheduled to run a backup on the first day of every month at 11:00 AM.
  • Next, these backups are set to delete 90 days after they’re create.
  • Then, uses the IAM role named AWSBackupDefaultServiceRole to run the backup job.
  • Finally, assigns the backup plan to all resources that are tagged with the key backup and the value thinbackup.
AWSTemplateFormatVersion: "2010-09-09"
Description: "Backup Plan template for thin backups"
Resources:
BackupVaultWithThinBackups:
Type: "AWS::Backup::BackupVault"
Properties:
BackupVaultName: "BackupVaultWithThinBackups"
BackupPlanWithThinBackups:
Type: "AWS::Backup::BackupPlan"
Properties:
BackupPlan:
BackupPlanName: "BackupPlanWithThinBackups"
AdvancedBackupSettings:
-
ResourceType: EC2
BackupOptions:
WindowsVSS: enabled
BackupPlanRule:
-
RuleName: "RuleForDailyBackups"
TargetBackupVault: !Ref BackupVaultWithThinBackups
ScheduleExpression: "cron(25 11 ? * * *)"
Lifecycle:
DeleteAfterDays: 7
CopyActions:
-
DestinationBackupVaultArn: arn:aws:backup:us-west-2:111222333444:backup-vault:Default
Lifecycle:
DeleteAfterDays: 14
-
RuleName: "RuleForWeeklyBackups"
TargetBackupVault: !Ref BackupVaultWithThinBackups
ScheduleExpression: "cron(0 11 ? * 2 *)"
Lifecycle:
DeleteAfterDays: 28
CopyActions:
-
DestinationBackupVaultArn: arn:aws:backup:us-west-2:111222333444:backup-vault:Default
Lifecycle:
DeleteAfterDays: 14
-
RuleName: "RuleForMonthlyBackups"
TargetBackupVault: !Ref BackupVaultWithThinBackups
ScheduleExpression: "cron(0 11 1 * ? *)"
Lifecycle:
DeleteAfterDays: 90
CopyActions:
-
DestinationBackupVaultArn: arn:aws:backup:us-west-2:111222333444:backup-vault:Default
Lifecycle:
DeleteAfterDays: 14
DependsOn: BackupVaultWithThinBackups

TagBasedBackupSelection:
Type: "AWS::Backup::BackupSelection"
Properties:
BackupSelection:
SelectionName: "TagBasedBackupSelection"
IamRoleArn: !Sub "arn:aws:iam::${AWS::AccountId}:role/service-role/AWSBackupDefaultServiceRole"
ListOfTags:
-
ConditionType: "STRINGEQUALS"
ConditionKey: "backup"
ConditionValue: "thinbackup"
BackupPlanId: !Ref BackupPlanWithThinBackups
DependsOn: BackupPlanWithThinBackups

[Need help with AWS queries? We’d be happy to assist you]

 

Conclusion

In short, we saw how our Support Techs manage AWS Backup settings using AWS CloudFormation templates.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

server management

Spend time on your business, not on your servers.

TALK TO US

Or click here to learn more.

Speed issues driving customers away?
We’ve got your back!

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF