How to Backup DynamoDB Table: Simple Steps and Example
To backup a DynamoDB table, use the
CreateBackup API or AWS CLI to create an on-demand backup. This saves the table data and settings at a point in time, which you can restore later if needed.Syntax
The CreateBackup API requires the table name and a backup name. It creates a full backup of the table data and settings.
TableName: The name of the DynamoDB table to backup.BackupName: A unique name for the backup.
bash
aws dynamodb create-backup --table-name <TableName> --backup-name <BackupName>
Example
This example shows how to create an on-demand backup of a DynamoDB table named Users with the backup name UsersBackup2024 using AWS CLI.
bash
aws dynamodb create-backup --table-name Users --backup-name UsersBackup2024
Output
{
"BackupDetails": {
"BackupName": "UsersBackup2024",
"BackupArn": "arn:aws:dynamodb:region:account-id:table/Users/backup/015f...",
"BackupStatus": "CREATING",
"BackupCreationDateTime": "2024-06-01T12:00:00.000Z",
"TableName": "Users",
"BackupSizeBytes": 0
}
}
Common Pitfalls
Common mistakes when backing up DynamoDB tables include:
- Using a backup name that already exists, causing an error.
- Not having the right IAM permissions to create backups.
- Confusing on-demand backups with continuous backups (point-in-time recovery).
Always ensure your backup names are unique and your AWS user has dynamodb:CreateBackup permission.
bash
aws dynamodb create-backup --table-name Users --backup-name UsersBackup2024
# Error: Backup with this name already exists
# Correct approach: Use a unique backup name
aws dynamodb create-backup --table-name Users --backup-name UsersBackup2024_v2Quick Reference
| Command | Description |
|---|---|
| aws dynamodb create-backup --table-name | Create an on-demand backup of a DynamoDB table |
| aws dynamodb list-backups --table-name | List all backups for a table |
| aws dynamodb delete-backup --backup-arn | Delete a specific backup |
| aws dynamodb restore-table-from-backup --target-table-name | Restore a table from a backup |
Key Takeaways
Use the CreateBackup API or AWS CLI to create on-demand backups of DynamoDB tables.
Backup names must be unique to avoid errors during creation.
Ensure your AWS user has the necessary permissions to create backups.
On-demand backups capture the full table state at a point in time for later restoration.
Use list-backups and restore-table-from-backup commands to manage backups.