How to Restore a DynamoDB Table Quickly and Safely
To restore a DynamoDB table, use the
RestoreTableFromBackup API or AWS CLI command with the backup ARN and a new table name. This creates a new table restored to the backup state without affecting the original table.Syntax
The RestoreTableFromBackup operation requires specifying the target table name and the backup ARN. The new table name must be unique in your AWS account and region.
TargetTableName: The name for the restored table.BackupArn: The Amazon Resource Name of the backup to restore from.
bash
aws dynamodb restore-table-from-backup --target-table-name <new-table-name> --backup-arn <backup-arn>
Example
This example shows how to restore a DynamoDB table named UsersBackup to a new table called UsersRestored using AWS CLI.
bash
aws dynamodb restore-table-from-backup \ --target-table-name UsersRestored \ --backup-arn arn:aws:dynamodb:us-west-2:123456789012:table/UsersBackup/backup/015f7f3a-1234-5678-90ab-cdef12345678
Output
{
"TableDescription": {
"TableName": "UsersRestored",
"TableStatus": "RESTORING",
"ProvisionedThroughput": {
"ReadCapacityUnits": 5,
"WriteCapacityUnits": 5
},
"ItemCount": 0,
"TableSizeBytes": 0
}
}
Common Pitfalls
- Using the same table name: You cannot restore a backup to a table name that already exists in your account and region.
- Backup ARN mistakes: Ensure the backup ARN is correct and the backup is in the same region.
- Restore time: The restore process can take several minutes; the table status will be
RESTORINGuntil complete. - Permissions: Your AWS user must have
dynamodb:RestoreTableFromBackuppermission.
bash
## Wrong: Using existing table name aws dynamodb restore-table-from-backup --target-table-name UsersBackup --backup-arn <backup-arn> ## Right: Use a new unique table name aws dynamodb restore-table-from-backup --target-table-name UsersRestored --backup-arn <backup-arn>
Quick Reference
| Parameter | Description |
|---|---|
| TargetTableName | Name of the new table to create from backup |
| BackupArn | ARN of the backup to restore |
| TableStatus | Status of the restored table (e.g., RESTORING, ACTIVE) |
| Permissions | Requires dynamodb:RestoreTableFromBackup permission |
Key Takeaways
Restoring a DynamoDB table creates a new table; it does not overwrite the original.
Always specify a unique target table name when restoring from backup.
Use the backup ARN from the same AWS region as your restore operation.
Restoration can take several minutes; monitor the table status until ACTIVE.
Ensure your AWS user has the correct permissions to restore tables.