Skip to content

feat(backup): support continuous backup and point-in-time restores - #17602

Merged
mergify[bot] merged 9 commits into
aws:masterfrom
jumic:backup-enableContinuousBackup
Dec 17, 2021
Merged

mergify[bot] merged 9 commits into
aws:masterfrom
jumic:backup-enableContinuousBackup

Conversation

@jumic

@jumic jumic commented Nov 19, 2021 •

Copy link
Copy Markdown
Contributor

Adds support for continuous backup and point-in-time restores.

Implemented validations when continuous backup and point-in-time restores is enabled:

  • deleteAfter between 1 and 35 days. "The minimum retention period is 1 day. The maximum retention period is 35 days." (see docs)
  • deleteAfter must be specified. Mandatory in AWS console. CloudFormation error if not specified: Lifecycle must be specified for backup rule enabled continuous backup
  • moveToColdStorageAfter is not supported. Field not available in AWS console. CloudFormation error if specified: MoveToColdStorageAfterDays is unavailable

Closes #15922.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io

gitpod-io Bot commented Nov 19, 2021

Copy link
Copy Markdown

@jumic jumic changed the title feat(backup): support continuous backup and point-in-time restores feat(backupplan): support continuous backup and point-in-time restores Nov 19, 2021
@github-actions github-actions Bot added the @aws-cdk/aws-backup Related AWS Backup label Nov 19, 2021
@jumic jumic changed the title feat(backupplan): support continuous backup and point-in-time restores feat(backup): support continuous backup and point-in-time restores Nov 19, 2021
@kaizencc
kaizencc self-requested a review November 30, 2021 22:57
@kaizencc kaizencc added effort/small Small work item – less than a day of effort p2 labels Nov 30, 2021

@kaizencc kaizencc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed PR description, it was very helpful. My main comment is that I think we should default deleteAfter to Duration.days(35) if not supplied. We should still be documenting these limitations both in the README and in the docstring as well, though.

Comment thread packages/@aws-cdk/aws-backup/README.md Resolved
Comment thread packages/@aws-cdk/aws-backup/README.md Resolved
@mergify
mergify Bot dismissed kaizencc’s stale review December 8, 2021 19:25

Pull request has been modified.

@jumic
jumic requested a review from kaizencc December 8, 2021 19:26

@kaizencc kaizencc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great @jumic! Just a few more minor nits.

}

if (props.enableContinuousBackup && props.deleteAfter &&
((props.deleteAfter?.toSeconds() < Duration.days(1).toSeconds() ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I would prefer just props.deleteAfter?.toDays() < 1 || props.deleteAfter?.toDays() > 35

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to change it. Now, the test case failed with message
Received message: "'12 hours' cannot be converted into a whole number of days.".
Should I change it anyway? I would prefer the existing solution because it shows a clear error message.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually requires some more investigation. Can you confirm the granularity that deleteAfter allows? I know its called deleteAfterDays on cloudformation but that it also accepts a double. Which makes me think we are allowed fractions of days. On our side, we convert deleteAfter to days here (so we would run into the message you got anyway):

deleteAfterDays: rule.props.deleteAfter?.toDays(),

This could be a small bug, in that our checks are more stringent then cloudformation.

If you're interested in checking this out, please do! If not, I like even more the conditional I suggested. It looks like the current CDK behavior is that deleteAfter must be a whole number of days, so it is good to stay with that level of granularity here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it as proposed. I checked some other modules in CDK where Duration is used. It's implemented in the same way.
The granularity of deleteAfter is days. Message "'12 hours' cannot be converted into a whole number of days." indicates that developers have to specify deleteAfter in days if something else is used. If this is resolved, the logic checks if deleteAfter has a valid range. So it's fine for me. :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I am misunderstanding you. But the '12 hours... error message comes from the line I linked above. It is a CDK limitation. I am weary of this because it seems like Cloudformation may allow fractions of days. This is good for now, I'll create an issue to investigate this further.

@jumic
jumic requested a review from kaizencc December 14, 2021 17:57
@mergify
mergify Bot dismissed kaizencc’s stale review December 14, 2021 17:57

Pull request has been modified.

kaizencc
kaizencc previously approved these changes Dec 17, 2021
@mergify
mergify Bot dismissed kaizencc’s stale review December 17, 2021 20:13

Pull request has been modified.

@jumic

jumic commented Dec 17, 2021

Copy link
Copy Markdown
Contributor Author

Build failed (npm ERR! notarget No matching version found for @aws-cdk/[email protected].). Should be solved with the current master branch.
Could you approve this PR again, please? Thanks.

@mergify

mergify Bot commented Dec 17, 2021

Copy link
Copy Markdown
Contributor

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation

Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 149847b
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
mergify Bot merged commit 24c6ef5 into aws:master Dec 17, 2021
@mergify

mergify Bot commented Dec 17, 2021

Copy link
Copy Markdown
Contributor

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
…ws#17602)

Adds support for [continuous backup and point-in-time restores](https://docs.aws.amazon.com/aws-backup/latest/devguide/point-in-time-recovery.html).

Implemented validations when continuous backup and point-in-time restores is enabled:
- `deleteAfter` between 1 and 35 days. "The minimum retention period is 1 day. The maximum retention period is 35 days." (see [docs](https://docs.aws.amazon.com/aws-backup/latest/devguide/point-in-time-recovery.html#point-in-time-recovery-working-with))
- `deleteAfter` must be specified. Mandatory in AWS console. CloudFormation error if not specified: `Lifecycle must be specified for backup rule enabled continuous backup`
- `moveToColdStorageAfter` is not supported. Field not available in AWS console. CloudFormation error if specified: `MoveToColdStorageAfterDays is unavailable`

Closes aws#15922.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
ali-n4i pushed a commit to ali-n4i/aws-cdk that referenced this pull request Jul 29, 2026
…ws#17602)

Adds support for [continuous backup and point-in-time restores](https://docs.aws.amazon.com/aws-backup/latest/devguide/point-in-time-recovery.html).

Implemented validations when continuous backup and point-in-time restores is enabled:
- `deleteAfter` between 1 and 35 days. "The minimum retention period is 1 day. The maximum retention period is 35 days." (see [docs](https://docs.aws.amazon.com/aws-backup/latest/devguide/point-in-time-recovery.html#point-in-time-recovery-working-with))
- `deleteAfter` must be specified. Mandatory in AWS console. CloudFormation error if not specified: `Lifecycle must be specified for backup rule enabled continuous backup`
- `moveToColdStorageAfter` is not supported. Field not available in AWS console. CloudFormation error if specified: `MoveToColdStorageAfterDays is unavailable`

Closes aws#15922.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

@aws-cdk/aws-backup Related AWS Backup effort/small Small work item – less than a day of effort p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(aws-backup): add support for EnableContinuousBackup in BackupPlanRule

3 participants