AWS from zero · Part 3: Storage and data · Lesson 19 of 38 · about 50 minutes

Backups and disaster recovery: RPO, RTO and a tested restore

Part 3 ends where every storage lesson pointed: getting things back. AWS Backup protects the bakery's orders table and recipe bucket under one plan chosen by tag. Then the shop keeps trading, a disaster deletes the table and every version of every recipe, and both come back, with the two numbers that matter measured for real: 54 minutes of changes lost, and 7 minutes 55 seconds to recover. Plus the two runs that went wrong first, and what they teach.

By the end you'll know

  • What RPO and RTO mean, how to measure them, and why they're business decisions before they're technical ones
  • The four disaster recovery strategies, from backup and restore to active-active, and what each costs
  • How AWS Backup works: vaults, plans, rules and selections by tag
  • How to restore, what a restore doesn't bring back, and why an untested backup is only a hope
  • How backups are protected from the people, and the attackers, who might delete them

Before you start

  • You need: the juniper-rye profile from Lesson 4, signed in, and Lessons 15 to 18: the lab protects a DynamoDB table and an S3 bucket.
  • The script: backup-lab.sh from the practice folder's lesson-19. Everything it creates is named jr-lesson19-*, and its delete step removes it, backups included.
  • How the script talks to AWS: only through the AWS CLI. The few lines of Python in it just turn the CLI's JSON into readable tables and never connect to AWS; boto3, AWS's Python library, comes in Lesson 20.
  • To see every call the script makes, put SHOW=1 in front of any step, such as SHOW=1 ./backup-lab.sh plan. The lesson's "By hand" section lists them all too.
  • Where you run things: your own machine, labeled (Your machine).
  • Run the steps one at a time, and only go on to disaster once backup says both jobs finished. The lesson shows why.
  • Every output below is from real runs on November 11, 2026. The first two runs failed in different ways, and both are in the lesson.

Backups in the same account can be deleted with everything else

Anyone who can delete your data in an account can usually delete its backups too, and ransomware attacks go after backups first. This lab keeps backups in the same account, which is fine for practice. Real ones are copied to a separate account, and locked so nobody, not even an administrator, can delete them early.

The short version

  • RPO (recovery point objective) is how much data you can afford to lose; RTO (recovery time objective) is how long you can afford to be down. The business sets both; the design has to meet them.
  • AWS Backup protects many services under one plan, picking resources by tag, and keeps the backups in a vault.
  • A backup captures the data as it was when the job started, even if the job takes half an hour to finish.
  • A restore makes new copies, under new names, and needs its own permissions and settings.
  • Until you've restored a backup, you don't know it works. Two of this lesson's three runs proved that.

What this lesson costs

PartCost, in us-east-2
AWS Backup storageDynamoDB $0.10 and S3 $0.05 per GB a month: this lab stores a few KB
RestoresDynamoDB $0.15 per GB, S3 $0.012 per GB: fractions of a cent
The table, the buckets and their requestsWell under 1 cent
This lessonUnder 1 cent a run, from credits

The two numbers

Every disaster recovery plan comes down to two questions, asked of the business, not of the engineers:

RPO, recovery point objectiveRTO, recovery time objective
AsksHow much data can we lose?How long can we be down?
MeasuredBackwards from the disaster, to the last good copyForwards from the disaster, to working again
Set byHow often you back up or copyHow fast you can restore and switch over
For the bakery"Losing today's orders would hurt; losing a minute's wouldn't""The shop can't take orders while it's down"

Here is the lab's real timeline, with both marked:

RPO looks back from the disaster to the moment the backup captured. RTO looks forward to working again.

Both numbers get smaller as you spend more. Backing up hourly instead of daily shrinks RPO; keeping a second copy running elsewhere shrinks RTO. That's why the business sets them: someone has to decide what an hour of lost orders, or an hour of downtime, is worth.

The four strategies

The Solutions Architect exam names four ways to recover, from cheapest and slowest to dearest and fastest:

StrategyWhat's ready in the second placeRPORTOCost
Backup and restoreBackups only. Everything else is built after the disaster.HoursHours$
Pilot lightThe data, copied continuously; servers defined but offMinutesTens of minutes$$
Warm standbyA small working copy of everything, scaled up when neededSeconds to minutesMinutes$$$
Multi-site, active-activeA full copy, serving customers all the timeNear zeroNear zero$$$$

This lesson builds the first. Lesson 17's Multi-AZ standby and Lesson 18's global tables are pieces of the others: copies kept ready, rather than rebuilt.

Is it allowed, and what does it cost?

(Your machine)

BASH
cd ~/Apps/aws-practice/lesson-19
chmod +x backup-lab.sh
./backup-lab.sh fence
OUTPUT
== Is this allowed in us-east-2?
  AWS Backup: allowed
  AWS Backup may protect DynamoDB: True, S3: True
  advanced DynamoDB backups (managed fully by AWS Backup): True
== What it costs, in us-east-2
  backup storage: DynamoDB $0.10 per GB a month, S3 $0.05 per GB a month: this lab stores a few KB
  restores:       DynamoDB $0.15 per GB, S3 $0.012 per GB: fractions of a cent
  the table, bucket and requests: well under 1 cent
  this lab: under 1 cent, if delete runs the same day

AWS Backup has a per-Region switch for each kind of resource it may protect, the opt-in. Both DynamoDB and S3 were on. "Advanced DynamoDB backups" means AWS Backup manages DynamoDB backups fully, with features like copying them to other accounts.

What to protect, and the plan

In the console: AWS Backup > Backup vaults > Create backup vault; then Backup plans > Create backup plan > Build a new plan; then the plan > Assign resources, with Include specific resource types and a tag condition.

(Your machine)

BASH
./backup-lab.sh build
./backup-lab.sh plan

From the third run:

OUTPUT
== The orders table, tagged backup=daily
== The recipe bucket, jr-lesson19-recipes-2691a6, with versioning on (AWS Backup needs it for S3), tagged backup=daily
== What there is to protect
  jr-lesson19-orders:                1001 sourdough, 1002 baguette, 1003 croissant
  jr-lesson19-recipes-2691a6:        recipes/croissant.txt, recipes/rye.txt, recipes/sourdough.txt
== A role AWS Backup takes on to back up and restore, with AWS's four managed policies for it
== A backup vault, where the backups are kept, encrypted
== A backup plan: every day at 05:00 UTC, kept 7 days, for anything tagged backup=daily
== The plan
  rule daily: cron(0 5 * * ? *), into jr-lesson19-vault, deleted after 7 days
  selection tagged-daily: every resource whose tag backup equals daily
PartDoesThe lab's
Backup vaultHolds backups, called recovery points, encrypted, with its own access policyjr-lesson19-vault
Backup planOne or more rules saying when to back up and how long to keep itjr-lesson19-daily
RuleA schedule, a vault, and a lifecycle05:00 UTC daily, kept 7 days
Resource selectionWhich resources the plan covers: by name, or by tagAnything tagged backup=daily
RoleWhat AWS Backup acts as when it backs up and restoresjr-lesson19-backup-role, with AWS's four managed policies for backups, restores, and S3's of each

Selecting by tag is the habit worth copying. The plan names nothing: tag a new table or bucket backup=daily, and tomorrow's run includes it. Nobody has to remember to add it to the plan, and in a real account a rule can require the tag on every new resource (Lesson 35).

The schedule is a cron expression, like Linux's from the Linux track's Scripts and cron, with AWS's extra field for the year. S3 needs versioning on before AWS Backup will protect a bucket.

Backing up, and the shop keeps trading

In the console: AWS Backup > Protected resources > Create on-demand backup.

(Your machine)

BASH
./backup-lab.sh backup
OUTPUT
== Backing up both now, on demand, rather than waiting for 05:00
  DynamoDB  COMPLETED after 188 seconds
  S3        COMPLETED after 1563 seconds
  both jobs finished at 2026-11-11T20:11:04Z
== The vault now: each recovery point holds the data as it was when its backup started
  DynamoDB  recovery point ...6d3a22c0e674  COMPLETED  data as of 2026-11-11T19:44:59Z
  S3        recovery point ...501-30218f55  COMPLETED  data as of 2026-11-11T19:45:00Z
== Business carries on: one more order and one more recipe, after the backup
  jr-lesson19-orders:                1001 sourdough, 1002 baguette, 1003 croissant, 1004 rye
  jr-lesson19-recipes-2691a6:        recipes/croissant.txt, recipes/focaccia.txt, recipes/rye.txt, recipes/sourdough.txt
BASH
aws backup start-backup-job --backup-vault-name jr-lesson19-vault --resource-arn "$TABLE_ARN" \
  --iam-role-arn "$ROLE_ARN" --lifecycle DeleteAfterDays=7

Two things in that output. The S3 backup took 1,563 seconds, 26 minutes, for three tiny files; the first backup of a bucket is slow whatever its size. And each recovery point holds the data as of when its job started, 19:45, not when it finished at 20:11. That start time is what RPO counts from, which the lab's first run got wrong, as below.

The disaster

(Your machine)

BASH
./backup-lab.sh disaster
OUTPUT
== 2026-11-11T20:39:43Z: the disaster. The table is deleted, and every version of every recipe with it
  table jr-lesson19-orders: deleted
  bucket jr-lesson19-recipes-2691a6: 4 object versions deleted, nothing left to undo
  the table:                         gone
  the recipes:                       

The table is gone, and so is every version of every recipe, so Lesson 15's versioning can't help: this is what a careless script, a compromised account or ransomware looks like. Only the vault has copies.

Restoring, and the two numbers

In the console: AWS Backup > Backup vaults > the vault > select a recovery point > Actions > Restore.

(Your machine)

BASH
./backup-lab.sh restore
OUTPUT
== A bucket to restore the recipes into, jr-lesson19-restored-dec418, with versioning on (the restore requires it)
== Restoring both from the vault
  S3: restore started
  DynamoDB: restore started
  S3: COMPLETED
  DynamoDB: COMPLETED
== What came back
  jr-lesson19-orders-restored:       1001 sourdough, 1002 baguette, 1003 croissant
  jr-lesson19-restored-dec418:       recipes/croissant.txt, recipes/rye.txt, recipes/sourdough.txt
== The two numbers that matter
  RPO, DynamoDB: data as of 2026-11-11T19:44:59Z, disaster at 2026-11-11T20:39:43Z: 54 min 44 s of changes lost
  RPO, S3:       data as of 2026-11-11T19:45:00Z, disaster at 2026-11-11T20:39:43Z: 54 min 43 s of changes lost
           what was lost: order 1004 and the focaccia recipe, both added after the backups started
  RTO:     7 min 55 s from the disaster to both restored (not counting the time to notice it)
BASH
aws backup start-restore-job --recovery-point-arn "$TABLE_RECOVERY_POINT" --iam-role-arn "$ROLE_ARN" \
  --resource-type DynamoDB --metadata targetTableName=jr-lesson19-orders-restored
aws backup start-restore-job --recovery-point-arn "$BUCKET_RECOVERY_POINT" --iam-role-arn "$ROLE_ARN" \
  --resource-type S3 --metadata DestinationBucketName=jr-lesson19-restored-dec418,EncryptionType=original,RestoreACLs=false

Everything the backups captured came back, and nothing after them did. Order 1004 and the focaccia recipe were added after 19:45, so they're the 54 minutes of changes lost: the RPO. Getting back took 7 minutes 55 seconds: the RTO.

Both numbers are kinder than real life. With the daily plan, a disaster at 04:59 loses almost 24 hours of orders: the worst-case RPO is the time between backups. And the RTO here starts the moment of the disaster. A real one also counts the time until someone notices, and the time to point the app at jr-lesson19-orders-restored and the new bucket, since a restore always makes new copies with new names.

A restoreSo
Makes new copies, under names you giveThe app needs pointing at them, or the data copying back
Needs a role with restore permissionsThe lab's role had AWS's restore policies, for S3 as well
For S3, needs a destination bucket with versioning onThe script made one first
Doesn't restore settings around the dataTags, alarms, recovery settings and access policies, as Lesson 18 saw

The two runs that went wrong

The output above is from the third run. The first two failed, and each failure is something teams only find by testing.

The first run's S3 restore failed:

OUTPUT
  S3: FAILED  (Cannot restore, as the BucketOwnershipControls of jr-lesson19-restored-4f1f79 do not allow the use of object ACLs.)

AWS Backup copies each object's ACLs, S3's old per-object permissions, and by default tries to restore them. But new buckets have ACLs switched off, as Lesson 15 showed, so there was nowhere to put them, and the whole restore was refused. RestoreACLs=false fixed it. The DynamoDB half restored fine, so a team that only ever tested the table would have learned this during a real disaster.

That run also reported the RPO as 33 seconds, measured from when the backup jobs finished. The real figure was about 27 minutes, from when they started. The script now reads each recovery point's own time.

The second run's S3 backup never started:

OUTPUT
aws: [ERROR]: An error occurred (InvalidParameterValueException) when calling the StartBackupJob operation: IAM Role does not have sufficient permissions to execute the backup

The role had been created moments before, and IAM takes a little while before a brand-new role can be used everywhere. Worse, the steps had been pasted in all at once, so disaster ran anyway and deleted the originals with no finished backup of the bucket. In a real system, that's the end of the data. The script now retries while a new role settles in, and refuses to run disaster unless the vault holds a completed backup of both the table and the bucket.

Check that a backup finished, and test that it restores, before you need it. Two runs out of three would have lost data; both were caught because the restore was actually tried.

Keeping backups safe, described

FeatureDoes
Cross-account copyCopies each backup to a vault in a separate backup account, which the production account can't touch
Cross-Region copyCopies to another Region, for a Region-wide disaster. The free plan's one-Region limit stops it here.
Vault LockStops anyone deleting backups before their retention ends. In compliance mode, after a grace period, nobody can remove the lock, not even AWS support.
Logically air-gapped vaultA vault locked by default and owned by AWS's own account, shared to you, for recovering after an account is compromised
Restore testingRestores chosen backups on a schedule, checks them, and deletes the copies: this lesson's restore, automated
Backup Audit ManagerReports which resources are protected, and whether plans meet rules like "kept 35 days"

Take it down

In the console: AWS Backup > the vault > select every recovery point > Actions > Delete; then delete the vault and the plan. Delete the tables and buckets from their own consoles.

(Your machine)

BASH
./backup-lab.sh delete
OUTPUT
== Deleting table jr-lesson19-orders-restored
== Deleted bucket jr-lesson19-recipes-2691a6
== Deleted bucket jr-lesson19-restored-dec418
== Deleted the backup plan
== Deleted 2 recovery points
== Deleted the vault
== Deleted role jr-lesson19-backup-role
== Left over from this lab
  tables:           0
  buckets:          0
  backup plans:     0
  backup vaults:    0
  IAM role:         0
== Backups that bill, anywhere in us-east-2
  DynamoDB backups: 0
  backup vaults:    0 (AWS creates an empty Default one when you first open AWS Backup)

A vault can't be deleted while it holds recovery points, or while a backup job is still running in it. The second run's delete hit exactly that, with its half-finished DynamoDB job, so the script now waits for running jobs first. The role goes last, because AWS Backup needs it until every job is done.

By hand: every command the script runs

The same lab without the script, in order. It leaves out tags on the table and bucket, which are set when they're created, and the waiting loops; SHOW=1 ./backup-lab.sh plan prints the exact calls as they run. (Your machine)

BASH
export AWS_PROFILE=juniper-rye AWS_REGION=us-east-2

# Check AWS Backup may protect these kinds of resource here
aws backup describe-region-settings

# The role AWS Backup acts as, with AWS's four managed policies
aws iam create-role --role-name jr-lesson19-backup-role \
  --assume-role-policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"backup.amazonaws.com"},"Action":"sts:AssumeRole"}]}'
aws iam attach-role-policy --role-name jr-lesson19-backup-role --policy-arn arn:aws:iam::aws:policy/service-role/AWSBackupServiceRolePolicyForBackup
aws iam attach-role-policy --role-name jr-lesson19-backup-role --policy-arn arn:aws:iam::aws:policy/service-role/AWSBackupServiceRolePolicyForRestores
aws iam attach-role-policy --role-name jr-lesson19-backup-role --policy-arn arn:aws:iam::aws:policy/AWSBackupServiceRolePolicyForS3Backup
aws iam attach-role-policy --role-name jr-lesson19-backup-role --policy-arn arn:aws:iam::aws:policy/AWSBackupServiceRolePolicyForS3Restore

# The vault, the plan, and the selection by tag
aws backup create-backup-vault --backup-vault-name jr-lesson19-vault
PLAN=$(aws backup create-backup-plan --backup-plan file://plan.json --query BackupPlanId --output text)
aws backup create-backup-selection --backup-plan-id "$PLAN" --backup-selection file://selection.json

# A backup now, and what's in the vault
aws backup start-backup-job --backup-vault-name jr-lesson19-vault --resource-arn "$TABLE_ARN" \
  --iam-role-arn "$ROLE_ARN" --lifecycle DeleteAfterDays=7
aws backup start-backup-job --backup-vault-name jr-lesson19-vault --resource-arn "arn:aws:s3:::$BUCKET" \
  --iam-role-arn "$ROLE_ARN" --lifecycle DeleteAfterDays=7
aws backup describe-backup-job --backup-job-id "$JOB_ID"
aws backup list-recovery-points-by-backup-vault --backup-vault-name jr-lesson19-vault

# Restoring, each to a new name
aws backup start-restore-job --recovery-point-arn "$TABLE_RECOVERY_POINT" --iam-role-arn "$ROLE_ARN" \
  --resource-type DynamoDB --metadata targetTableName=jr-lesson19-orders-restored
aws backup start-restore-job --recovery-point-arn "$BUCKET_RECOVERY_POINT" --iam-role-arn "$ROLE_ARN" \
  --resource-type S3 --metadata DestinationBucketName="$NEW_BUCKET",EncryptionType=original,RestoreACLs=false
aws backup describe-restore-job --restore-job-id "$RESTORE_JOB_ID"

# Taking it down: tables and buckets, then the plan, the recovery points, the vault, and the role last
aws backup delete-backup-selection --backup-plan-id "$PLAN" --selection-id "$SELECTION_ID"
aws backup delete-backup-plan --backup-plan-id "$PLAN"
aws backup delete-recovery-point --backup-vault-name jr-lesson19-vault --recovery-point-arn "$RECOVERY_POINT"
aws backup delete-backup-vault --backup-vault-name jr-lesson19-vault

plan.json holds the rule shown in the plan output: cron(0 5 * * ? *), the vault, and "Lifecycle": {"DeleteAfterDays": 7}. selection.json holds the role and the tag condition, backup equals daily.

In real systems

  • The business signs off RPO and RTO for each system, and the backup plans are written to meet them: hourly or continuous for orders, daily for reports.
  • Backups are copied to a separate backup account, often in another Region, locked with Vault Lock, so a compromised production account can't delete them (Lesson 36).
  • Restore testing runs on a schedule, and its results go to the team, because a backup that has never been restored is a hope, not a plan.
  • A rule requires the backup tag on every database and bucket (Lesson 35), so nothing is left out by accident.
  • The recovery runbook is written down and practiced, including how to point the app at restored copies: the part this lab's RTO didn't count.
  • The plans, vaults and selections are Terraform, like everything else from Part 5 on.

Spot the problem

Work out what's wrong before you read the explanation.

"Our backups were deleted along with everything else." An attacker gets an administrator's access keys for the bakery's production account. They delete the database, the buckets, and then every recovery point in the backup vault, which is in the same account. The plan ran perfectly every night. What's wrong? The backups lived where the attacker already had full control. Anyone who can delete the data could delete the backups. The fix: copy every backup to a vault in a separate backup account, and lock that vault with Vault Lock, so the production account can't delete the copies, and nobody can delete them early. Then check: from the production account, does deleting a recovery point in the backup account fail with AccessDenied?

Keep this

RememberWhy
RPO: data you can lose; RTO: time you can be downThe business sets them, and they set the cost
Worst-case RPO is the time between backupsA daily plan can lose almost a day
A backup captures when it startsThe 26-minute S3 job still held 19:45's data
Select resources by tagNew resources are protected without editing the plan
Restores make new copiesPoint the app at them; that's part of the RTO
S3 restores into ACL-free buckets need RestoreACLs=falseOr the whole restore is refused
Confirm the backup finished before you need itThe second run deleted data with no backup
Copy backups to another account, and lock themWhoever can delete the data can delete local backups

Where you are now

The bakery has a backup plan that protects anything tagged for it, and you've done what most teams never do: deleted the originals and restored them, measuring 54 minutes of lost changes and 7 minutes 55 seconds to recover. Two broken runs taught you to check a backup finished and to test that it restores. That's the end of Part 3. Part 4 starts with Lesson 20, where the scripts become Python: the same AWS calls, through boto3.

Check yourself

  1. The backup jobs finished at 20:11, and the disaster was at 20:39:43. What was the RPO?

  2. The bakery backs up once a day at 05:00. What's its worst-case RPO?

  3. Why does the lab's plan select resources by tag?

  4. Why did the first run's S3 restore fail?

  5. What did the second run do that a real team must never do?

  6. Which strategy keeps a small working copy running, ready to scale up?

  7. An attacker has admin access to the production account. Where should the backups be?

Key terms

  • RPO (recovery point objective): how much data, measured in time, you can afford to lose.
  • RTO (recovery time objective): how long you can afford to be down.
  • Disaster recovery (DR): getting back after losing a system, a zone, a Region or the data itself.
  • Backup and restore, pilot light, warm standby, active-active: the four DR strategies, from cheapest to fastest.
  • AWS Backup: one service for backing up many others, on plans.
  • Backup vault: where AWS Backup keeps backups, encrypted.
  • Recovery point: one backup in a vault.
  • Backup plan and rule: when to back up, into which vault, and for how long.
  • Resource selection: which resources a plan covers, by name or tag.
  • Opt-in: AWS Backup's per-Region switch for each resource type.
  • Restore job: creating new copies from a recovery point.
  • Vault Lock: stops anyone deleting backups before their retention ends.
  • Restore testing: AWS Backup restoring and checking backups on a schedule.

Go deeper