Amazon DynamoDB Backup & Restore

15 December,2022 by Rambler

DynamoDB supports On-Demand backups and Point-In-Time backups 

Notes on DynamoDB backups

1) When PITR is enabled , DynamoDB maintains continuous backups and can restore to any point in time between the EarliestRestorableDateTime and LatestRestorableDateTime

2) PITR needs to be enabled on a DynamoDB table by table basis 

 

How to check the PITR status 

Example 1 : PITR status is enabled

aws dynamodb describe-continuous-backups --table-name abc1

{
    "ContinuousBackupsDescription": {
        "ContinuousBackupsStatus": "ENABLED",
        "PointInTimeRecoveryDescription": {
            "PointInTimeRecoveryStatus": "ENABLED",
            "EarliestRestorableDateTime": "2022-11-02T13:36:19.311000+00:00",
            "LatestRestorableDateTime": "2022-12-07T13:31:19.311000+00:00"
        }
    }
}

Example 2: PITR is disabled

aws dynamodb describe-continuous-backups --table-name abc2


{
    "ContinuousBackupsDescription": {
        "ContinuousBackupsStatus": "ENABLED",
        "PointInTimeRecoveryDescription": {
            "PointInTimeRecoveryStatus": "DISABLED"
        }
    }
}



How to enable PITR on a DynamoDB table

aws dynamodb update-continuous-backups --table-name MyDynamoDBtable --point-in-time-recovery-specification PointInTimeRecoveryEnabled=true

 

How to Restore a DynamoDB to point-in-time  table using AWS CLI

Note: PITR recovery restores to a new table

OPTION 1 : Restore to the latest Restorable times 

aws dynamodb restore-table-to-point-in-time --source-table-name MyDynamoDBtable --target-table-name MyDynamoDBtable-restore  --use-latest-restorable-time

OPTION 2 : Restore to a specific point in time 

Note: To get a specific restore-date-time 

aws dynamodb restore-table-to-point-in-time --source-table-name <replace_with_source_tbl_> --target-table-name <replace_with_target_tbl> --no-use-latest-restorable-time --restore-date-time <replace_with_restore_date_time>

 

Along with data, the following settings are also restored to the new DynamoDB table:

Global secondary indexes (GSIs)
Local secondary indexes (LSIs)
Provisioned read and write capacity
Encryption settings


There are a few settings that will need to be manually set up on the restored table and are not copied over:

Auto scaling policies
AWS Identity and Access Management (IAM) policies
AWS CloudWatch metrics and alarms
Tags
Stream settings
Time-to-Live (TTL) settings
Point-in-time recovery settings

 

How to Restore A DynamoDB Table - assuming the AWS Backup plan is used

--get the DynamoDB table Resource ARN

aws dynamodb describe-table --table-name <replace_with_DynamoDB_table_name> --query Table.TableArn

--get the backup resource ARN .This query will return  1 or more backup recovery points - with date and Recovery PointARN. Select the RecoveryPointARN as required

aws backup list-backup-jobs --by-state COMPLETED --query "BackupJobs[?ResourceArn == '<replace_with_DynamoDB_Resource_ARN>'].[CompletionDate,RecoveryPointArn]"

-- execute the restore command

aws dynamodb restore-table-from-backup --target-table-name  <REPLACE_WITH_TARGET_TBL> --backup-arn  <REPLACE_WITH_BACKUP_RESOURCE_ARN>


Author: Rambler (http://www.dba-ninja.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on Amazon DynamoDB Backup & Restore


dba-ninja.com