Skip to content

Commit 115d33a

Browse files
jrm16020bchew
authored andcommitted
Limit thread count, support backup by tags, compressed backups and storage in S3 (#33)
* Limit thread count, support backup by tags, compressed backups and storage in S3 * Single quote to double quote where possible * Rebase to get new changes and update quotes * Flake8 fixes
1 parent f42f31c commit 115d33a

File tree

3 files changed

+623
-160
lines changed

3 files changed

+623
-160
lines changed

README.md

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ dynamodump supports local DynamoDB instances as well (tested with [dynalite](htt
1212
Usage
1313
-----
1414
```
15-
usage: dynamodump.py [-h] [-m MODE] [-r REGION] [--host HOST] [--port PORT]
16-
[--accessKey ACCESSKEY] [--secretKey SECRETKEY]
17-
[-p PROFILE] [-s SRCTABLE] [-d DESTTABLE]
18-
[--prefixSeparator PREFIXSEPARATOR] [--noSeparator]
19-
[--readCapacity READCAPACITY]
15+
usage: dynamodump.py [-h] [-a {zip,tar}] [-b BUCKET] [-m MODE] [-r REGION]
16+
[--host HOST] [--port PORT] [--accessKey ACCESSKEY]
17+
[--secretKey SECRETKEY] [-p PROFILE] [-s SRCTABLE]
18+
[-d DESTTABLE] [--prefixSeparator PREFIXSEPARATOR]
19+
[--noSeparator] [--readCapacity READCAPACITY] [-t TAG]
2020
[--writeCapacity WRITECAPACITY] [--schemaOnly]
2121
[--dataOnly] [--skipThroughputUpdate]
2222
[--dumpPath DUMPPATH] [--log LOG]
@@ -25,9 +25,16 @@ Simple DynamoDB backup/restore/empty.
2525
2626
optional arguments:
2727
-h, --help show this help message and exit
28+
-a {zip,tar}, --archive {zip,tar}
29+
Type of compressed archive to create.If unset, don't
30+
create archive
31+
-b BUCKET, --bucket BUCKET
32+
S3 bucket in which to store or retrieve backups.[must
33+
already exist]
2834
-m MODE, --mode MODE 'backup' or 'restore' or 'empty'
2935
-r REGION, --region REGION
30-
AWS region to use, e.g. 'us-west-1'. Use 'local' for
36+
AWS region to use, e.g. 'us-west-1'. Can use
37+
AWS_DEFAULT_REGION for local testing. Use 'local' for
3138
local DynamoDB testing
3239
--host HOST Host of local DynamoDB [required only for local]
3340
--port PORT Port of local DynamoDB [required only for local]
@@ -42,7 +49,7 @@ optional arguments:
4249
-s SRCTABLE, --srcTable SRCTABLE
4350
Source DynamoDB table name to backup or restore from,
4451
use 'tablename*' for wildcard prefix selection or '*'
45-
for all tables
52+
for all tables. Mutually exclusive with --tag
4653
-d DESTTABLE, --destTable DESTTABLE
4754
Destination DynamoDB table name to backup or restore
4855
to, use 'tablename*' for wildcard prefix selection
@@ -56,6 +63,8 @@ optional arguments:
5663
--readCapacity READCAPACITY
5764
Change the temp read capacity of the DynamoDB table to
5865
backup from [optional]
66+
-t TAG, --tag TAG Tag to use for identifying tables to back up. Mutually
67+
exclusive with srcTable. Provided as KEY=VALUE
5968
--writeCapacity WRITECAPACITY
6069
Change the temp write capacity of the DynamoDB table
6170
to restore to [defaults to 25, optional]
@@ -112,6 +121,24 @@ python dynamodump.py -m backup -r us-west-1 -p source_credentials -s "*" --schem
112121
python dynamodump.py -m restore -r us-west-1 -p destination_credentials -s "*" --schemaOnly
113122
```
114123

124+
Backup all tables based on AWS tag `key=value`
125+
```
126+
python dynamodump.py -p profile -r us-east-1 -m backup -t KEY=VALUE
127+
```
128+
129+
Backup all tables based on AWS tag, compress and store in specified S3 bucket.
130+
```
131+
python dynamodump.py -p profile -r us-east-1 -m backup -a tar -b some_s3_bucket -t TAG_KEY=TAG_VALUE
132+
133+
python dynamodump.py -p profile -r us-east-1 -m backup -a zip -b some_s3_bucket -t TAG_KEY=TAG_VALUE
134+
```
135+
136+
Restore from S3 bucket to specified destination table
137+
```
138+
## source_table identifies archive file in S3 bucket from which backup data is restored
139+
python2 dynamodump.py -a tar -b some_s3_bucket -m restore -r us-east-1 -p profile -d destination_table -s source_table
140+
```
141+
115142
Local example
116143
-------------
117144
The following assume your local DynamoDB is running on localhost:4567 and is accessible via 'a' as access/secret keys.

0 commit comments

Comments
 (0)