Restoring a DynamoDB Table from a Backup - Amazon DynamoDB

Restoring a DynamoDB Table from a Backup

This section describes how to restore a table from a backup using the Amazon DynamoDB console or the AWS Command Line Interface (AWS CLI).

Note

If you want to use the AWS CLI, you must configure it first. For more information, see Accessing DynamoDB.

Restoring a Table from a Backup (Console)

The following procedure shows how to restore the Music table by using the MusicBackup file that is created in the Backing Up a DynamoDB Table tutorial.

Note

This procedure assumes that the Music table no longer exists before restoring it using the MusicBackup file.

To restore a table from a backup

  1. Sign in to the AWS Management Console and open the DynamoDB console at https://console.aws.amazon.com/dynamodb/.

  2. In the navigation pane on the left side of the console, choose Backups.

  3. In the list of backups, choose MusicBackup.

    
                        Screenshot of the backups list and the create backup
                            button.
  4. Choose Restore backup.

    
                        Screenshot of the backups list with the restore backup button
                            highlighted.
  5. Enter Music as the new table name. Confirm the backup name and other backup details. Then choose Restore table to start the restore process.

    Note

    You can restore the table to the same AWS Region or to a different Region from where the backup resides. You can also exclude secondary indexes from being created on the new restored table. In addition, you can specify a different encryption mode.

    
                        Screenshot of the restore table from backup screen with backup table
                            details.

    The table that is being restored is shown with the status Creating. After the restore process is finished, the status of the Music table changes to Active.

    
                        Screenshot of the tables list with Active status.

Restoring a Table from a Backup (AWS CLI)

Follow these steps to use the AWS CLI to restore the Music table using the MusicBackup that is created in the Backing Up a DynamoDB Table tutorial.

To restore a table from a backup

  1. Confirm the backup that you want to restore by using the list-backups command. This example uses MusicBackup.

    aws dynamodb list-backups

    To get additional details for the backup, use the describe-backup command. You can get the input backup-arn from the previous step.

    aws dynamodb describe-backup \ --backup-arn arn:aws:dynamodb:us-east-1:123456789012:table/Music/backup/01489173575360-b308cd7d
  2. Restore the table from the backup. In this case, the MusicBackup restores the Music table to the same AWS Region.

    aws dynamodb restore-table-from-backup \ --target-table-name Music \ --backup-arn arn:aws:dynamodb:us-east-1:123456789012:table/Music/backup/01489173575360-b308cd7d
  3. Restore the table from the backup with custom table settings. In this case, the MusicBackup restores the Music table and specifies an encryption mode for the restored table.

    Note

    The sse-specification-override parameter takes the same values as the sse-specification-override parameter used in the CreateTable command. To learn more, see Managing Encrypted Tables in DynamoDB.

    aws dynamodb restore-table-from-backup \ --target-table-name Music \ --backup-arn arn:aws:dynamodb:us-east-1:123456789012:table/Music/backup/01581080476474-e177ebe2 \ --sse-specification-override Enabled=true,SSEType=KMS,KMSMasterKeyId=abcd1234-abcd-1234-a123-ab1234a1b234

    You can restore the table to a different AWS Region from where the backup resides.

    Note
    • The sse-specification-override parameter is mandatory for cross-Region restores but optional for restores in the same Region as the source table.

    • When performing a cross-Region restore from the command line, you must set the default AWS Region to the desired destination Region. To learn more, see Command Line Options in the AWS Command Line Interface User Guide.

    aws dynamodb restore-table-from-backup \ --target-table-name Music \ --backup-arn arn:aws:dynamodb:us-east-1:123456789012:table/Music/backup/01581080476474-e177ebe2 \ --sse-specification-override Enabled=true,SSEType=KMS

    You can override the billing mode and the provisioned throughput for the restored table.

    aws dynamodb restore-table-from-backup \ --target-table-name Music \ --backup-arn arn:aws:dynamodb:us-east-1:123456789012:table/Music/backup/01489173575360-b308cd7d \ --billing-mode-override PAY_PER_REQUEST

    You can exclude some or all secondary indexes from being created on the restored table.

    Note

    Restores can be faster and more cost-efficient if you exclude some or all secondary indexes from being created on the restored table.

    aws dynamodb restore-table-from-backup \ --target-table-name Music \ --backup-arn arn:aws:dynamodb:us-east-1:123456789012:table/Music/backup/01581081403719-db9c1f91 \ --global-secondary-index-override '[]' \ --sse-specification-override Enabled=true,SSEType=KMS
    Note

    The secondary indexes provided should match existing indexes. You cannot create new indexes at the time of restore.

    You can use a combination of different overrides. For example, you can use a single global secondary index and change provisioned throughput at the same time, as follows.

    aws dynamodb restore-table-from-backup \ --target-table-name Music \ --backup-arn arn:aws:dynamodb:eu-west-1:123456789012:table/Music/backup/01581082594992-303b6239 \ --billing-mode-override PROVISIONED \ --provisioned-throughput-override ReadCapacityUnits=100,WriteCapacityUnits=100 \ --global-secondary-index-override IndexName=singers-index,KeySchema=["{AttributeName=SingerName,KeyType=HASH}"],Projection="{ProjectionType=KEYS_ONLY}",ProvisionedThroughput="{ReadCapacityUnits=5,WriteCapacityUnits=5}" \ --sse-specification-override Enabled=true,SSEType=KMS

To verify the restore, use the describe-table command to describe the Music table.

aws dynamodb describe-table --table-name Music

The table that is being restored from the backup is shown with the status Creating. After the restore process is finished, the status of the Music table changes to Active.

Important

While a restore is in progress, don't modify or delete your IAM role policy; otherwise, unexpected behavior can result. For example, suppose that you removed write permissions for a table while that table is being restored. In this case, the underlying RestoreTableFromBackup operation would not be able to write any of the restored data to the table. Note that IAM policies involving source IP restrictions for accessing the target restore table might similarly cause issues.

After the restore operation is complete, you can modify or delete your IAM role policy.

If your backup is encrypted with an AWS managed CMK or a customer managed CMK, don't disable or delete the key while a restore is in progress, or the restore will fail.

After the restore operation is complete, you can change the encryption key for the restored table and disable or delete the old key.