Skip to content
Tutorials Center
My learning

Topics

Lesson 31 of 37 ยท Streams, TTL and Integrations

Backups, PITR and Global Tables

Protect DynamoDB data with on-demand backups, point-in-time recovery and AWS Backup, and replicate across Regions with global tables, conflicts and failover.

DynamoDB is durable: your data is stored on several nodes in three Availability Zones. But durability is not the same as safety. A bug can overwrite good data, a bad deploy can delete a table, or a person can run the wrong script. You also may need low latency for users on another continent, or a plan for the day a whole Region is unavailable. This lesson covers the tools for both: backups and global tables.

On-demand backups

An on-demand backup is a full copy of a table at the moment you ask. It takes seconds or minutes regardless of table size and consumes no read capacity and does not slow the table. Backups stay until you delete them. You restore into a new table (you cannot restore over an existing one). The restore can take a while for big tables, because it is a copy.

Terminal
aws dynamodb create-backup --table-name Shop --backup-name shop-before-migration
aws dynamodb restore-table-from-backup \
  --target-table-name Shop-restored \
  --backup-arn arn:aws:dynamodb:eu-west-1:123456789012:table/Shop/backup/01700000000000-abcd1234

A restore brings back data, keys, secondary indexes and capacity settings. Some things are not restored automatically and need to be configured on the new table: auto scaling policies, IAM policies, CloudWatch alarms, stream settings, TTL settings and tags (you can opt in for some). Keep these in infrastructure code (see IaC and IAM).

Point-in-time recovery (PITR)

Point-in-time recovery continuously backs up the table. When it is enabled, you can restore the table to any second in the last 35 days (the retention is configurable between 1 and 35 days). Use it to undo an accidental delete or a faulty batch update: pick the time just before the mistake.

  • Off by default; enable it per table. It adds a storage-based cost.
  • Restores go into a new table, like on-demand backups.
  • It also powers full exports to S3 (see stream integrations).
Terminal
aws dynamodb update-continuous-backups --table-name Shop \
  --point-in-time-recovery-specification PointInTimeRecoveryEnabled=true
aws dynamodb restore-table-to-point-in-time \
  --source-table-name Shop --target-table-name Shop-at-0930 \
  --restore-date-time 2026-03-09T09:30:00Z

AWS Backup

AWS Backup centralizes schedules and retention across services. It supports DynamoDB with scheduled plans, cross-Region and cross-account copies, vault lock (immutability against deletion) and advanced features such as backups with long retention in cold storage. Use it when you need compliance policies or protection against a compromised account.

Protect the data

On-demand Full copy, any time
PITR Any second in 35 days
AWS Backup Schedules, copies, vault lock
Deletion protection Table cannot be deleted

Restores always create a new table.

1 / 2

Also enable deletion protection on important tables. It blocks DeleteTable until someone turns it off on purpose.

Try it: point-in-time restore on a change log

The idea behind PITR is a log of changes with timestamps. The stand-in below keeps such a log and rebuilds the table as of any time. This is an illustration, not the real implementation.

Python Rebuild a table as of a moment in time

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Restoring at t=3 brings back USER#2, and you would copy the missing item from the restored table into the live one.

Global tables

A global table replicates a table to several Regions. Each Region has a full, writable replica. A write in eu-west-1 is copied to us-east-1 and ap-southeast-1 typically within a second. Benefits:

  • Low-latency reads and writes for users near each replica.
  • Multi-Region resilience: if a Region is impaired, traffic can go to another. The service targets high availability SLAs (99.999% with global tables, compared with 99.99% for a single-Region table).

Requirements: the replicas need the same key schema, streams are used internally, and the current version (2019.11.21) lets you add a Region to an existing table. Each replica has its own capacity settings (use on-demand or auto scaling), and writes are billed in replicated write units per Region.

Conflict resolution

Two Regions can write the same item at nearly the same time. By default global tables use last writer wins, comparing the item's timestamp to decide. One write wins entirely and the other disappears; there is no merging of attributes. Newer multi-Region strong consistency options exist for specific cases and have their own limits and latency costs, so check the current documentation before relying on them.

To avoid conflicts, design for Region affinity: send a user's writes to one home Region (for example by routing on user ID) and use the others as read replicas and failover.

  • Strongly consistent reads and conditional checks only see data in their own Region (see consistency models).
  • Transactions are atomic only in the Region that runs them.
  • Do not use a counter incremented from two Regions: with last writer wins you can lose increments.
Python Last writer wins across two Regions

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Both Regions converged on the later write, and the earlier edit disappeared. That is acceptable for profile data edited by one person, but never for balances.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Where does a DynamoDB restore put the data?

    Both on-demand and point-in-time restores create a new table. You then switch the application or copy items.
  2. 2. How far back can PITR restore by default (maximum)?

    PITR keeps a continuous history for a configurable window of 1 to 35 days.
  3. 3. How do global tables resolve conflicting writes by default?

    The write with the later timestamp replaces the other one entirely. Design around it with Region affinity.
  4. 4. Which setting protects a table from accidental DeleteTable calls?

    With deletion protection enabled, DeleteTable fails until the setting is disabled.

Summary

  • On-demand backups and PITR restore into a new table without using read capacity; PITR covers up to 35 days.
  • AWS Backup adds schedules, cross-Region and cross-account copies and vault lock.
  • Enable deletion protection and keep settings in code, because restores do not carry everything.
  • Global tables replicate to several Regions with last-writer-wins conflicts; prefer one home Region per item.
  • Strong reads and transactions are limited to their own Region.

Next: AWS CLI and SDKs