Lesson 4 of 7 Amazon RDS and Aurora

Backing Up and Restoring RDS Databases

This lesson explains how RDS backs databases up automatically and restores them to any second within a retention period, always as a new database instance.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish automated backups from snapshots.
  • Explain how point-in-time restore creates a new instance.
  • Choose a cross-Region recovery option.

Backup types

RDS protects data with two kinds of backup. Automated backups combine a daily snapshot with transaction logs that are copied continuously, so the database can be restored to any second within a retention period of 1 to 35 days. This is point-in-time recovery, the way to undo a mistake such as a deleted table. Every restore creates a new database instance, so the application must be pointed at its endpoint.

Manual snapshots are taken on demand and kept until they are deleted, even after the instance is gone, so they suit long-term retention and the state before a risky change. They can be copied to other Regions and shared with other accounts; an encrypted snapshot can be shared only if it uses a customer managed KMS key. AWS Backup manages RDS backups with central backup plans, copies across accounts and Regions, and locked vaults. The following table summarises the types.

TypeBehaviour
Automated backupsDaily snapshot plus transaction logs: point-in-time recovery to any second within a retention period of 1 to 35 days
Manual snapshotsKept until deleted; copy across Regions and share with other accounts (encrypted ones only with a customer managed key)
AWS BackupCentral backup plans, cross-account and cross-Region copies, locked vaults

Automated backups are deleted with the instance unless retained; take a final snapshot before deleting a production database.

35days

Maximum automated backup retention

True or false

RDS backups

Exam skills 4.3.1 · 1.3.5

Check how RDS automated backups and snapshots work.

Log in to try this activity Interactive activities are free with an account.

Restoring

Restoring an RDS backup or snapshot always creates a new database instance with a new endpoint; it never overwrites the existing database. Applications must therefore be pointed at the new endpoint, or the old instance renamed and the new one given its name.

Point-in-time recovery restores the database to any chosen second within the backup retention period, for example just before an accidental DELETE. Restoring also provides a way to change a database: a snapshot can be restored with a different instance class, and an unencrypted database can be encrypted by restoring from an encrypted copy of its snapshot.

The following diagram shows a point-in-time restore after an accidental DELETE.

Point-in-time recovery after an accidental DELETE. The database is restored to a chosen second within the backup retention period, just before the mistake. The restore always creates a new instance with a new endpoint, so the application must be pointed at it, or the instances renamed.
The times and names are illustrative. The original instance is left as it was until it is deleted.

Disaster recovery options

RDS offers three ways to recover a database in another Region, which differ in how much data could be lost. Cross-Region automated backup replication copies the automated snapshots and transaction logs to the second Region, so point-in-time recovery is possible there, losing at most a few minutes of changes. Cross-Region snapshot copies are taken on a schedule, so the recovery point is the time of the last copy, which may be hours old.

A cross-Region read replica receives changes continuously, so it is usually only seconds behind, and it is already running: recovery means promoting it to a standalone database, which gives the fastest recovery at the cost of running the replica all the time. The following table summarises the options.

OptionRecovery point
Cross-Region automated backup replicationMinutes, with point-in-time recovery in the second Region
Cross-Region snapshot copiesThe time of the last copy
Cross-Region read replicaSeconds of lag; fastest recovery
Sort into groups

Recovery point by option

Exam skills 2.2.6 · 1.3.5

Match each cross-Region recovery option with its typical recovery point.

Log in to try this activity Interactive activities are free with an account.
Worked example

Undoing an accidental delete

At 14:32 a faulty script deletes thousands of rows from a production RDS database. The deletion is noticed at 15:10.

StepAction
1Restore the database to 14:31 with point-in-time recovery; RDS creates a new instance
2Copy the deleted rows from the restored instance back into production
3Delete the temporary instance

Restoring the whole database would also roll back legitimate changes made after 14:32, so the team copies only the lost rows. Because every restore creates a new instance, the production endpoint never changes.

Check yourself

Does restoring an RDS backup overwrite the existing database?

Show answer

No. A restore always creates a new DB instance with a new endpoint, so applications must be pointed at it.

Exam Tips

Remember for the exam

  • To restore the database to its state 10 minutes ago, use point-in-time recovery, which creates a new instance.
  • Automated backups keep up to 35 days of point-in-time recovery.
  • To share a snapshot with another account, copy or create it with a customer managed key.
  • To keep point-in-time recovery in another Region, enable cross-Region automated backup replication.