Reputation: 161
I have enabled the Point-in-time-recovery on my dynamodb table. So it will handle the creation of incremental backups. when i tried to restore from backup it is creating a new dynamodb table. Can't we restore to same dynamodb table? If not, what is the best way to do, without impacting the performance of dynamodb table?
Upvotes: 13
Views: 16218
Reputation: 1498
Following on the suggestion given by @matt_linker, I developed a small script that can be used as a starting point. However, this script considers a recovery scenario from PITR. Notice I didn't bother on writing wait loops to wait some processes to finish (e.g.: restore-table-to-point-in-time) so I recommend you run each command individually.
export SOURCE_TABLE="backup-test"
export TARGET_TABLE="backup-test-restored"
export RESTORE_TO="2024-01-05T12:50:00-08:00"
# Restore using PITR
aws dynamodb restore-table-to-point-in-time \
--source-table-name $SOURCE_TABLE \
--target-table-name $TARGET_TABLE \
--restore-date-time $RESTORE_TO
# Once restore completed, create an on-demand backup
export BACKUP_ARN=$(aws dynamodb create-backup \
--table-name $TARGET_TABLE \
--backup-name "$TARGET_TABLE-on-demand-backup" \
--query 'BackupDetails.BackupArn' \
--output text)
# Once on-demand backup completed, delete the original table
aws dynamodb delete-table \
--table-name $SOURCE_TABLE
# Once original table deleted, restore from on-demand backup into original table
aws dynamodb restore-table-from-backup \
--target-table-name $SOURCE_TABLE \
--backup-arn $BACKUP_ARN
Upvotes: 3
Reputation: 187
Not ideal, but you could try this. Make a backup of Table_A, restore to Table_B. Take a backup of Table_B. Drop Table_A. Restore Table_B as Table_A. And drop Table_B.
Upvotes: 16
Reputation: 4855
At this time, you can only restore with PITR to another table. I know this sounds terrible, but it is done so the original table cannot be blown away and you are protected and you have options on how you want to restore.
Your best bet is to just repoint your application at the new table. Failing that, you will need to create a process that will update the original table from the newly restored table, if that is your intent.
Upvotes: 15