Backups, restore and cloning
Automated backups and point-in-time restore for RDS and Aurora, manual snapshots, restoring from S3, and fast Aurora clones with copy-on-write.
What it is
RDS and Aurora protect the data in two ways: automated backups, which go back to any second in a window of days, and manual snapshots, which are kept as long as needed. Aurora adds cloning, a fast copy of a whole cluster.
The one rule to remember: a restore always creates a new database. It never overwrites the existing one.
RDS automated backups
- Once a day, during the chosen backup window, RDS takes a full backup of the instance (a storage snapshot).
- Every 5 minutes, RDS uploads the database's transaction logs to S3.
- Together they allow point-in-time recovery: restore to any second from the oldest backup up to about 5 minutes ago.
- Automated backups are kept for 1 to 35 days. On RDS, setting 0 turns them off (not recommended).
Automated backups are deleted with the instance unless they're set to be retained.
Manual DB snapshots
- The customer starts a snapshot (or a schedule in AWS Backup does).
- It's kept until it's deleted, even after the database is gone.
- Use them before risky changes, for long-term retention, and to copy a database to another Region or share it with another account.
Exam tip
A stopped RDS instance still pays for its storage, and RDS starts it again after 7 days. To switch a database off for a long time, take a snapshot, delete the instance, and restore the snapshot when it's needed.
Aurora backups
- Automated backups are continuous and incremental, kept 1 to 35 days, and can't be turned off.
- Point-in-time recovery to any second in that window.
- Manual snapshots work as on RDS: kept until deleted.
- Backtrack (Aurora MySQL) rewinds the existing cluster in place, up to 72 hours, without a restore.
Restore options
- Restore a backup or snapshot: creates a new RDS instance or Aurora cluster, with a new endpoint. Point the application at it.
- Restore MySQL on RDS from S3:
- Back up the on-premises MySQL database (for example with
mysqldumpor XtraBackup). - Upload the backup files to Amazon S3.
- Restore them onto a new RDS for MySQL instance.
- Back up the on-premises MySQL database (for example with
- Restore MySQL into Aurora from S3:
- Back up the on-premises database with Percona XtraBackup (this physical backup is required).
- Upload the files to Amazon S3.
- Restore them into a new Aurora MySQL cluster.
Aurora database cloning
Aurora cloning creates a new Aurora cluster from an existing one, much faster than snapshot and restore.
- At first the clone uses the same storage pages as the source. Nothing is copied, so it's ready in minutes, even for a huge database.
- When either cluster changes a page, Aurora writes a new page for that cluster only. This is the copy-on-write protocol.
- Billing is only for the pages that differ, so clones are cheap.
The classic use: create a staging database from production to test a change on real data, without touching production. Up to 15 copy-on-write clones can be made per source cluster, and clones can be shared across accounts with AWS RAM.
Real-world examples
- A developer drops the wrong table at 14:35. The team restores the instance to 14:34:59 as a new instance, checks it, and points the app at it.
- A finance company must keep year-end data for seven years. It takes a manual snapshot each December and copies it to a second Region.
- A team tests a schema migration on an Aurora clone of production, made in five minutes, then deletes the clone.
Exam tips
- "Restore to a specific time a few minutes ago" → automated backups with point-in-time recovery (up to 35 days).
- "Keep a backup for years", "after the database is deleted" → manual snapshot.
- "Move an on-premises MySQL database to Aurora" → Percona XtraBackup files in S3, restore into Aurora (or AWS DMS).
- "Create a test or staging copy of production quickly and cheaply" → Aurora cloning.
- "Pause an RDS database for months" → snapshot, delete, restore later.
Common traps
- "Restoring overwrites the existing database." It always creates a new one.
- "Aurora automated backups can be disabled." Only RDS allows 0 days; Aurora's minimum is 1 day.
- "Automated backups are kept forever." At most 35 days; use manual snapshots for longer.
- "A clone copies all the data first." Copy-on-write shares pages until they change.
Hands-on lab: point-in-time restore
Goal: make a change, then restore the database to the moment before it, and see that a restore makes a new instance.
Costs money
Two db.t4g.micro instances for under an hour: about $0.04. Any Region works.
Before you start: create saa-db as in the RDS lab, and wait about 10 minutes after it's available so the first backup exists.
Make a change
From saa-web, create a table, note the time, then delete the table:
psql -h <endpoint> -U postgres -c "create table orders(id int); insert into orders values (1);"
date -u
sleep 600
psql -h <endpoint> -U postgres -c "drop table orders;"Restore to before the mistake
Select saa-db → Actions → Restore to point in time. Choose Custom date and time and enter a UTC time between the date output and the drop. Identifier saa-db-restored, db.t4g.micro, same VPC and security groups. Restore.
Check the result
When saa-db-restored is available, its endpoint is new. Run select * from orders; against it: the table and its row are back. The original saa-db still has no table.
Expected result: a second database containing the data as it was before the mistake; the original is unchanged.
Clean up: delete saa-db-restored and saa-db (no final snapshots, no retained backups), then the rds-ec2-* and ec2-rds-* security groups.
AWS documentation
Aurora advanced
Aurora Serverless for variable workloads, cross-Region replicas and Aurora Global Database, Aurora machine learning, and Babelfish for SQL Server applications.
Security and RDS Proxy
Encryption at rest and in transit, IAM database authentication, security groups and audit logs for RDS and Aurora, and RDS Proxy for connection pooling and faster failover.