0
0
AwsHow-ToBeginner · 3 min read

How to Set Backup Retention Period for AWS RDS Instances

To set the backup retention period for an AWS RDS instance, use the BackupRetentionPeriod parameter when creating or modifying the instance. This value defines how many days automated backups are kept, ranging from 0 (no backups) to 35 days.
📐

Syntax

The BackupRetentionPeriod parameter specifies the number of days to retain automated backups for an RDS instance.

  • Value range: 0 to 35 days
  • 0 means: automated backups are disabled
  • Used in: AWS CLI, AWS Console, CloudFormation, Terraform
bash
aws rds modify-db-instance \
    --db-instance-identifier mydbinstance \
    --backup-retention-period 7
💻

Example

This example shows how to set the backup retention period to 7 days for an existing RDS instance using AWS CLI.

bash
aws rds modify-db-instance \
    --db-instance-identifier mydbinstance \
    --backup-retention-period 7 \
    --apply-immediately
Output
An immediate modification is applied to the DB instance 'mydbinstance'. Automated backups will be retained for 7 days.
⚠️

Common Pitfalls

  • Setting BackupRetentionPeriod to 0 disables automated backups, which means no point-in-time recovery.
  • Retention period cannot exceed 35 days; setting a higher value causes errors.
  • Changes without --apply-immediately may delay backup retention update until the next maintenance window.
bash
aws rds modify-db-instance \
    --db-instance-identifier mydbinstance \
    --backup-retention-period 40

# Wrong: 40 exceeds max allowed days

aws rds modify-db-instance \
    --db-instance-identifier mydbinstance \
    --backup-retention-period 7 \
    --apply-immediately

# Correct: sets retention to 7 days immediately
📊

Quick Reference

ParameterDescriptionValue RangeNotes
BackupRetentionPeriodDays to keep automated backups0-350 disables backups
--apply-immediatelyApply changes immediatelytrue/falseWithout it, changes wait for maintenance window
DBInstanceIdentifierName of the RDS instancestringUnique identifier of your DB instance

Key Takeaways

Set BackupRetentionPeriod between 0 and 35 days to control automated backup duration.
A value of 0 disables automated backups and point-in-time recovery.
Use --apply-immediately to update backup retention without waiting for maintenance.
Backup retention changes can be made via AWS CLI, Console, or Infrastructure as Code.
Always verify retention settings to ensure backups meet your recovery needs.