Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yegor256/dynamo-archive
Archive and Restore DynamoDB Tables, from the Command Line
https://github.com/yegor256/dynamo-archive
amazon-dynamo amazon-dynamodb archive aws backup dynamodb javascript json
Last synced: 5 days ago
JSON representation
Archive and Restore DynamoDB Tables, from the Command Line
- Host: GitHub
- URL: https://github.com/yegor256/dynamo-archive
- Owner: yegor256
- License: other
- Created: 2013-06-02T07:13:10.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2024-09-26T19:06:30.000Z (about 1 month ago)
- Last Synced: 2024-10-25T19:43:48.275Z (9 days ago)
- Topics: amazon-dynamo, amazon-dynamodb, archive, aws, backup, dynamodb, javascript, json
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/dynamo-archive
- Size: 249 KB
- Stars: 101
- Watchers: 6
- Forks: 32
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- jimsghstars - yegor256/dynamo-archive - Archive and Restore DynamoDB Tables, from the Command Line (JavaScript)
README
[![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/dynamo-archive)](http://www.rultor.com/p/yegor256/dynamo-archive)
[![npm](https://github.com/yegor256/dynamo-archive/actions/workflows/npm.yml/badge.svg)](https://github.com/yegor256/dynamo-archive/actions/workflows/npm.yml)
[![NPM version](https://badge.fury.io/js/dynamo-archive.svg)](http://badge.fury.io/js/dynamo-archive)There are two simple Node.js scripts that archive and restore an entire
[AWS Dynamo DB](http://aws.amazon.com/dynamodb/)
table in JSON format.Install it first (I assume you have
[Node.js](http://nodejs.org/) and
[Npm](https://npmjs.org/doc/install.html) installed already):```bash
$ npm install -g dynamo-archive
```Create a user in [Amazon IAM](http://aws.amazon.com/iam/)
and assign a policy to it ([how?](http://docs.aws.amazon.com/IAM/latest/UserGuide/ManagingPolicies.html)):```json
{
"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 first without arguments and read the output:
```bash
$ dynamo-archive.js
```To restore a table from a JSON file run:
```bash
$ 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](http://s3tools.org/s3cmd)):```bash
#/bin/bashAWS_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
```## How to contribute
Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
Make sure you build is green before you contribute
your pull request. You will need to have NodeJS and installed. Then:```
$ npm install
$ npm test
```If it's clean and you don't see any error messages, submit your pull request.