Enable point-in-time recovery in DynamoDB
Amazon DynamoDB point-in-time recovery (PITR) provides automatic backups of your DynamoDB table data. This section provides an overview of how the process works in DynamoDB.
Note
DynamoDB charges for PITR based on the size of each DynamoDB table, including table data and local secondary indexes. To determine your backup charges, DynamoDB continuously monitors the size of the tables that have PITR turned on. You're billed for PITR usage until you turn off PITR for each table.
Topics
Enabling point-in-time recovery
You can enable point-in-time recovery using the AWS Management Console, AWS Command Line Interface (AWS CLI), or the DynamoDB API. When enabled, point-in-time recovery provides continuous backups until you explicitly turn it off.
After you enable point-in-time recovery, you can restore to any point in time within
EarliestRestorableDateTime
and LatestRestorableDateTime
.
LatestRestorableDateTime
is typically five minutes before the current
time. For more information, see Restoring a DynamoDB table to a point in
time.
Note
The point-in-time recovery process always restores to a new table.
Enable PITR (console)
To enable PITR using the DynamoDB console
Navigate to the DynamoDB console.
Choose Tables from the left navigation and select your DynamoDB table.
From the Backups tab, for the Point in Time Recovery option, choose Edit.
Choose Turn on point-in-time recovery and then choose Save changes.
Enable PITR (AWS CLI)
Note
If you receive errors when running AWS CLI commands, see Troubleshoot AWS CLI errors. Make sure you're using the most recent AWS CLI version.
Run the update-continuous-backups
aws dynamodb update-continuous-backups \ --region us-east-1 \ --table-name <ddb-table-name> \ --point-in-time-recovery-specification PointInTimeRecoveryEnabled=true
Enable PITR (AWS CloudFormation)
Use the AWS::DynamoDB::Table resource with the PointInTimeRecoverySpecification
property turned on:
Resources: iotCatalog: Type: AWS::DynamoDB::Table Properties: ... PointInTimeRecoverySpecification: PointInTimeRecoveryEnabled: true
Request syntax example:
{ "PointInTimeRecoverySpecification": { "PointInTimeRecoveryEnabled": boolean }, "TableName": "string" }
Enable PITR (API)
Run the UpdateContinuousBackups API operation with the PointInTimeRecoverySpecification
parameter turned on.
Request syntax example:
{ "PointInTimeRecoverySpecification": { "PointInTimeRecoveryEnabled": boolean }, "TableName": "string" }
Response syntax example:
{ "ContinuousBackupsDescription": { "ContinuousBackupsStatus": "string", "PointInTimeRecoveryDescription": { "EarliestRestorableDateTime": number, "LatestRestorableDateTime": number, "PointInTimeRecoveryStatus": "string" } } }
Python
import boto3 dynamodb = boto3.client('dynamodb') response = dynamodb.update_continuous_backups( TableName=<table_name>, PointInTimeRecoverySpecification={ 'PointInTimeRecoveryEnabled': True } )
Delete a table with PITR enabled
When you delete a table that has point-in-time recovery enabled, DynamoDB automatically
creates a backup snapshot called a system backup and retains it for
35 days (at no additional cost). You can use the system backup to restore the deleted
table to the state it was in before deletion. All system backups follow a standard
naming convention of
table-name
$DeletedTableBackup
.
Note
Once a table with point-in-time recovery enabled is deleted, you can use system restore to restore that table to a single point in time: the moment just before deletion. You do not have the capability to restore a deleted table to any other point in time in the past 35 days.