Sub topic 12
Continuous backups and point-in-time recovery
What continuous backup adds
This chapter assumes you already know vaults, backup plans, rules, and the service role from earlier chapters. It also assumes you understand RPO (recovery point objective, the maximum amount of data loss you accept) and RTO (recovery time objective, the maximum time you accept to recover).
A scheduled rule in AWS Backup takes a snapshot at a fixed time. If your rule runs daily at 05:00 UTC and the data is damaged at 16:00, the newest snapshot is 11 hours old. Your RPO is therefore up to a day.
Continuous backup records changes as they happen. It lets you restore a resource to any second within a retention window. This is called point-in-time recovery (PITR). Use it when you want to restore to just before a bad deployment, an accidental delete, or a faulty batch job.
Supported resource types
Continuous backup is not available for every service. It works for these resource types:
| Resource type | How changes are captured |
|---|---|
| Amazon RDS (most engines) | Transaction logs are stored alongside the automated backups |
| Amazon Aurora | Continuous log capture for the cluster |
| Amazon S3 | Versioning and object change tracking in the bucket |
| SAP HANA on Amazon EC2 | Database logs from the SAP HANA agent |
Amazon DynamoDB, Amazon EBS, and Amazon EFS are not on this list. DynamoDB has its own native point-in-time recovery feature. EBS and EFS use snapshot-style backups only. Check the current AWS documentation for your engine and version before you design around PITR, because support changes over time.
Two prerequisites apply to S3. Versioning must be enabled on the bucket. The service role also needs the S3 backup permissions, which are in the AWS-managed backup policies for S3.
How the retention window works
A continuous backup rule has a maximum retention of 35 days. Any value from 1 to 35 days is valid. You can restore to any point from the moment the first continuous backup completes until the retention window ends.
You enable it with the EnableContinuousBackup flag on a rule. A rule with this flag set produces a continuous recovery point. A rule with this flag unset produces ordinary snapshot recovery points.
The two rule types can sit in the same plan. A common design is shown in the diagram below.
The continuous rule gives a fine-grained, short window. The snapshot rule gives long-term retention. Snapshot rules can keep data for years, which continuous rules cannot.
Defining a continuous rule
The plan file below has two rules. The first is continuous, the second takes a daily snapshot and keeps it for 90 days.
{
"BackupPlanName": "pitr-plus-daily",
"Rules": [
{
"RuleName": "ContinuousBackups",
"TargetBackupVaultName": "app-vault",
"ScheduleExpression": "cron(0 5 ? * * *)",
"EnableContinuousBackup": true,
"Lifecycle": {
"DeleteAfterDays": 35
}
},
{
"RuleName": "DailySnapshots",
"TargetBackupVaultName": "app-vault",
"ScheduleExpression": "cron(0 5 ? * * *)",
"StartWindowMinutes": 60,
"CompletionWindowMinutes": 180,
"Lifecycle": {
"DeleteAfterDays": 90
}
}
]
}Create the plan the same way you created earlier plans:
aws backup create-backup-plan \
--backup-plan file://plan.jsonSome points about the continuous rule:
- The schedule expression on a continuous rule does not set how often changes are captured. Capture is constant. The schedule only controls how the backup job is started.
- You cannot set
OptInToArchiveForSupportedResourcesor a cold storage transition on a continuous rule. Continuous recovery points cannot move to cold storage. - The retention must be 35 days or less. A larger value is rejected.
- Every resource assigned to this rule must be of a supported type. Assigning unsupported resource types, for example by a tag that matches an EBS volume, means those resources are skipped by the continuous rule. Keep your tags precise.
Restoring to a point in time
You restore a continuous recovery point by giving a restore time instead of choosing a snapshot. The restore creates a new resource. It does not overwrite the original.
First, list the recovery points for the resource and confirm that a continuous one exists:
aws backup list-recovery-points-by-resource \
--resource-arn arn:aws:rds:us-east-1:123456789012:db:orders-dbLook for a recovery point with "IsParent" or a recovery point type of CONTINUOUS. The output also shows the earliest and latest times you can restore to.
Then start the restore. For PITR you pass the recovery point ARN of the continuous recovery point and a restore time in the metadata. The exact metadata keys depend on the resource type, so get a template first:
aws backup get-restore-job-metadata \
--restore-job-id <restore-job-id>In the console the process is simpler. Choose the continuous recovery point, pick Restore to point in time, and enter a timestamp in UTC. The console fills in the metadata for you. In the CLI, you supply RestoreTime (or the equivalent key for your resource) in the metadata, along with the usual settings for the new resource such as the DB instance identifier.
The restore can only use a time inside the valid window. If you request a time after the latest restorable time, or before the earliest, the job fails.
Latest restorable time and lag
Continuous backup is near real time, not instant. The latest restorable time is usually a few minutes behind the current time. For RDS and Aurora, it depends on when transaction logs are shipped. If you need to restore to a moment seconds ago, the restore may be rejected until the log data catches up.
Plan for this in runbooks. After an incident, wait a few minutes before you choose a restore time, and choose a time a little before the damage rather than exactly at it.
Gotchas
- One continuous recovery point per resource and vault. A continuous backup is a single stream. It is not a series of separate points. The window slides forward as old data ages out.
- Changing a rule does not rewrite history. If you shorten the retention, older log data is removed. If you lengthen it, only data from that point on is kept for the longer period.
- Deleting the plan assignment stops the stream. If a resource stops matching the tag selection, the continuous backup stops. Data already captured stays until the retention ends.
- Snapshot rules still matter. A continuous recovery point cannot be copied the way snapshots are in every case. Cross-Region and cross-account copies of continuous backups are supported for some resource types, but the copy is stored as a snapshot, not as a continuous stream. Verify support for your resource before relying on this.
- KMS keys apply. The vault key encrypts the recovery data. If the key is disabled, restores fail.
- Cost. You pay for storage of the logs and changes for the full window, so a busy database can cost more than a daily snapshot.
Verify the result
After a PITR restore, confirm the new resource is correct before you switch traffic to it:
- Check that the restore job status is
COMPLETED. - Connect to the restored resource and query the rows or objects that changed shortly before the incident.
- Confirm that the data from after your chosen time is absent.
- Compare the schema, parameter group, and security groups with the original.
Exercise
Your orders database is an RDS instance. A faulty script deleted rows at 14:20 UTC. You have only a daily snapshot rule at 05:00 UTC. What change gives you the smallest possible data loss, and what limit applies to it?
Show answer
Add a rule with EnableContinuousBackup set to true for the instance, so you can restore to a time just before 14:20 UTC. The retention for a continuous rule can be at most 35 days. Keep the daily snapshot rule as well for longer-term retention.
Exercise
You set a continuous rule with DeleteAfterDays of 90. What happens, and why?
Show answer
The plan is rejected because continuous backups support a maximum retention of 35 days. Use a separate snapshot rule if you need to keep recovery points for 90 days.