Amazon RDS provides automated backups and manual snapshot capabilities to ensure your data is protected and recoverable.
Automated Backups
Automated backups are enabled by default when you create an RDS instance. They allow you to restore your database to any point in time within the backup retention period. Key aspects include:
-
Backup Window: Automated backups occur during a specified 30-minute backup window. You can customize this window or let RDS choose it automatically based on the region and availability zone.
-
Retention Period: You can set the retention period for automated backups, which can be from 1 to 35 days. By default, it is set to 7 days.
-
Storage: The storage required for automated backups is provided at no additional charge up to the size of the database. For instance, if you have a 100 GB database, you get 100 GB of backup storage for free.
-
Point-in-Time Recovery: Automated backups allow for point-in-time recovery within the retention period. You can restore your database to any second during the retention period.
Manual Snapshots
Manual snapshots are user-initiated backups of your DB instance. These snapshots can be created at any time and are retained until you explicitly delete them. Key aspects include:
-
Creation: You can create a manual snapshot via the AWS Management Console, AWS CLI, or RDS API.
-
Retention: Unlike automated backups, manual snapshots are not subject to a retention period and are stored until you delete them.
-
Restoration: You can restore a new DB instance from a manual snapshot at any time.
Backup Storage Costs
While automated backup storage up to the size of the database is free, additional storage used by manual snapshots and automated backups exceeding the database size incurs costs. Backup storage beyond the free allotment is charged at standard RDS rates.
Example Commands
Creating a Manual Snapshot Using AWS CLI
aws rds create-db-snapshot \
--db-snapshot-identifier mydbsnapshot \
--db-instance-identifier mydbinstance
This command creates a manual snapshot named mydbsnapshot for the DB instance mydbinstance.
Restoring a DB Instance from a Snapshot Using AWS CLI
aws rds restore-db-instance-from-db-snapshot \
--db-instance-identifier mynewdbinstance \
--db-snapshot-identifier mydbsnapshot
This command restores a new DB instance named mynewdbinstance from the snapshot mydbsnapshot.
Best Practices for RDS Backups
-
Define a Backup Policy: Establish a backup policy that aligns with your data retention and recovery requirements.
-
Monitor Backup Storage: Keep an eye on your backup storage usage to manage costs effectively.
-
Regularly Test Restores: Periodically test your backup restores to ensure that your backup and recovery process works as expected.
-
Use Multi-AZ Deployments: For critical databases, consider using Multi-AZ deployments to enhance availability and data durability.
-
Automate Snapshot Management: Use AWS Lambda and AWS CloudWatch Events to automate the creation and deletion of snapshots based on your retention policy.