Search code examples
amazon-web-servicesamazon-dynamodbdatabase-administration

Amazon DynamoDB backup from a table and restore to a new table


I am looking for a way to do below steps in Amazon DynamoDB:

  1. backup the table_A
  2. delete the table_A
  3. create a new table with the same name table_A
  4. fill the new table with the backup from step. 1

The purpose of this task is that I need to change the LSI(local secondary index) of table_A The only way of changing it is to create a new table. right? I also need to keep the data (it's no more than couple MBs)

So is it possible to do #3 and #4? Or is there any better approach of this whole thing? If this table is in production, what would be a reasonable approach?

Thanks in advance,


Solution

  • https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/backuprestore_HowItWorks.html

    Along with data, the following are also included (and can't be excluded) on the backups:

    • Global secondary indexes (GSIs)
    • Local secondary indexes (LSIs)
    • Streams
    • Provisioned read and write capacity

    Here is an approach I've used before:

    1. Take a backup of table_A (this is just in case anything goes wrong)
    2. Use Data Pipeline to extract the data in the DynamoDB table and put it in S3
    3. Create a new table with your LSI, table_B
    4. Load the data from S3 into table_B using Data Pipeline
    5. Check everything is OK. Backup table_B
    6. Delete table_A. Recreate it. Load the data in using Data Pipeline

    https://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-importexport-ddb.html

    Data Pipeline is pretty rubbish in terms of usability and logging, but it works just fine.