Skip to content

tnsatish/dynamo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is cloned from dynamo-archive and made other changes on top of that.

There are two simple Node.js scripts that archive and restore an entire AWS Dynamo DB table in JSON format.

Install it first (I assume you have Node.js and Npm installed already):

$ npm install dynamo-archive

Create a user in Amazon IAM and assign a policy to it (how?):

{
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["dynamodb:Scan", "dynamodb:DescribeTable"],
      "Resource": "arn:aws:dynamodb:us-east-1:019644334823:table/test"
    }
  ]
}

Where 019644334823 if your AWS account number, us-east-1 is AWS region, and test is the name of your Dynamo DB table (can be a *, if you grant access to all tables).

Run it from bin folder, first without arguments and read the output:

$ node describe.js
$ ./bin/dynamo-archive.js

To restore a table from a JSON file run:

$ ./bin/dynamo-restore.js

Crontab automation

I'd recommend to use this simple bash script to automate backups of your Dynamo DB tables and save them to S3 (I'm using s3cmd):

#/bin/bash

AWS_ACCESS_KEY_ID=AKIAJK.......XWGA5AA
AWS_SECRET_ACCESS_KEY=7aDUFa68GN....................IGcH0zTf3k
#optional endpoint for DynamoDB local
AWS_DYNAMODB_ENDPOINT=http://localhost:8000/
declare -a TABLES=(first second third)
for t in ${TABLES[@]}
do
  dynamo-archive/bin/dynamo-archive.js --table=$t > $t.json
  s3cmd --no-progress put $t.json s3://backup.example.com/dynamo/$t.json
  rm $t.json
done

About

Dynamo DB Utils

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published