Amazon DynamoDB Tutorial 0/30 lessons ~6 min read Lesson 28

    Backup, Point-in-Time Recovery, and Exports

    Mistakes happen: a migration overwrites attributes, a bug deletes items, an engineer runs the wrong script.

    Course progress0%
    Focus
    10 guided sections
    Practice signal
    Examples included
    Career prep
    Interview Q&A included

    Introduction

    Mistakes happen: a migration overwrites attributes, a bug deletes items, an engineer runs the wrong script. DynamoDB offers point-in-time recovery (PITR), on-demand backups, and exports to S3, none of which affect table performance. Knowing exactly what a restore does — and does not — bring back is part of every production runbook.

    Purpose of this lesson

    You will enable PITR, take an on-demand backup, restore to a point in time, and export a table to S3 for analytics.

    Understanding the topic

    Options:

    • PITR: continuous backups; restore to any second within the recovery period (up to 35 days).
    • On-demand backups: full backups kept until you delete them — take one before risky migrations.
    • AWS Backup: central schedules, retention, cross-account and cross-Region copies.
    • Restores always create a new table. Auto scaling policies, IAM policies, CloudWatch alarms, tags, stream settings, TTL settings, and PITR settings are not restored — reapply them.
    • Export to S3 (requires PITR) writes DynamoDB JSON or Ion files without consuming table capacity; incremental exports capture changes over a window.

    Step-by-step explanation

    1. Identify the incident window from logs or CloudTrail.
    2. Restore PITR to a new table at a time just before the incident.
    3. Re-enable streams, TTL, alarms, auto scaling, and tags on the restored table as needed.
    4. Compare restored and current data; copy back only the affected items (or switch traffic to the restored table).
    5. Write up the gap between restore time and switch-over, and how writes during that gap were handled.

    Syntax reference

    Runbook commands:

    bash
    # Enable PITR
    aws dynamodb update-continuous-backups --table-name ShopTable \
    --point-in-time-recovery-specification PointInTimeRecoveryEnabled=true
    # Before a migration
    aws dynamodb create-backup --table-name ShopTable --backup-name shoptable-pre-migration-2026-11-19
    # Restore to just before an incident
    aws dynamodb restore-table-to-point-in-time \
    --source-table-name ShopTable \
    --target-table-name ShopTable-restore-0955 \
    --restore-date-time 2026-11-19T09:55:00Z
    # Export for analytics (no table capacity consumed)
    aws dynamodb export-table-to-point-in-time \
    --table-arn arn:aws:dynamodb:us-east-1:123456789012:table/ShopTable \
    --s3-bucket shop-analytics-exports --export-format DYNAMODB_JSON

    Best practices

    • Enable PITR and deletion protection on every production table.
    • Take a named on-demand backup before every data migration.
    • Rehearse restores regularly and time them — restore time grows with table size.
    • Keep restore runbooks in infrastructure-as-code so settings are reapplied automatically.

    Common mistakes

    • Assuming a restore overwrites the existing table.
    • Forgetting to re-enable streams, so downstream consumers silently stop.
    • Using Scan-based scripts for analytics exports instead of Export to S3.

    Advanced interview questions

    Interview Prep

    Practice concise answers, then expand each card for the explanation.

    2 questions
    1IntermediateQuestionWhat does a DynamoDB restore not bring back?+

    Answer

    A restore creates a new table with the data, indexes, and capacity settings, but not auto scaling policies, IAM policies, CloudWatch alarms, tags, stream settings, TTL settings, or PITR settings. Those must be reconfigured.
    2BeginnerQuestionHow would you run analytics on DynamoDB data?+

    Answer

    Export to S3 (full or incremental) and query with Athena, Glue, or a warehouse. Exports need PITR and do not consume table read capacity.

    Hands-on exercise

    Hands-on (sandbox account): enable PITR, write ten items, note the time, delete three items, then restore to the noted time into a new table. Write a script that copies only the three missing items back to the original table.

    Summary

    PITR, on-demand backups, AWS Backup, and S3 exports cover recovery and analytics. Restores create new tables without several settings, so runbooks must reapply them.

    Ready to mark this lesson complete?Track your journey across the entire course.