|
1 | 1 | # dynamodump |
2 | 2 |
|
3 | | -  [](https://hub.docker.com/r/bchew/dynamodump/) |
| 3 | +[](https://badge.fury.io/py/dynamodump) |
| 4 | + |
| 5 | + |
4 | 6 |
|
5 | 7 | Simple backup and restore script for Amazon DynamoDB using AWS SDK for Python (boto3) to work similarly to mysqldump. |
6 | 8 |
|
7 | 9 | Suitable for DynamoDB usages of smaller data volume which do not warrant the usage of AWS Data Pipeline for backup/restores/empty. |
8 | 10 |
|
9 | 11 | dynamodump supports local DynamoDB instances as well (tested with [DynamoDB Local](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html)). |
10 | 12 |
|
| 13 | +## Installation |
| 14 | + |
| 15 | +``` |
| 16 | +pip install dynamodump |
| 17 | +``` |
| 18 | + |
11 | 19 | ## Usage |
12 | 20 |
|
13 | 21 | ``` |
14 | | -usage: dynamodump.py [-h] [-a {zip,tar}] [-b BUCKET] |
| 22 | +usage: dynamodump [-h] [-a {zip,tar}] [-b BUCKET] |
15 | 23 | [-m {backup,restore,empty}] [-r REGION] [--host HOST] |
16 | 24 | [--port PORT] [--accessKey ACCESSKEY] |
17 | 25 | [--secretKey SECRETKEY] [-p PROFILE] [-s SRCTABLE] |
@@ -96,73 +104,73 @@ As of v1.2.0, note that `--noConfirm` is required to perform data restores invol |
96 | 104 | Single table backup/restore: |
97 | 105 |
|
98 | 106 | ``` |
99 | | -python dynamodump.py -m backup -r us-west-1 -s testTable |
| 107 | +dynamodump -m backup -r us-west-1 -s testTable |
100 | 108 |
|
101 | | -python dynamodump.py -m restore -r us-west-1 -s testTable |
| 109 | +dynamodump -m restore -r us-west-1 -s testTable |
102 | 110 | ``` |
103 | 111 |
|
104 | 112 | Multiple table backup/restore (assumes prefix of 'production-' of table names, use --prefixSeparator to specify a |
105 | 113 | different separator): |
106 | 114 |
|
107 | 115 | ``` |
108 | | -python dynamodump.py -m backup -r us-west-1 -s production* |
| 116 | +dynamodump -m backup -r us-west-1 -s production* |
109 | 117 |
|
110 | | -python dynamodump.py -m restore -r us-west-1 -s production* |
| 118 | +dynamodump -m restore -r us-west-1 -s production* |
111 | 119 | ``` |
112 | 120 |
|
113 | 121 | The above, but between different environments (e.g. production-_ tables to development-_ tables): |
114 | 122 |
|
115 | 123 | ``` |
116 | | -python dynamodump.py -m backup -r us-west-1 -s production* |
| 124 | +dynamodump -m backup -r us-west-1 -s production* |
117 | 125 |
|
118 | | -python dynamodump.py -m restore -r us-west-1 -s production* -d development* |
| 126 | +dynamodump -m restore -r us-west-1 -s production* -d development* |
119 | 127 | ``` |
120 | 128 |
|
121 | 129 | Backup all tables and restore only data (will not delete and recreate schema): |
122 | 130 |
|
123 | 131 | ``` |
124 | | -python dynamodump.py -m backup -r us-west-1 -s "*" |
| 132 | +dynamodump -m backup -r us-west-1 -s "*" |
125 | 133 |
|
126 | | -python dynamodump.py -m restore -r us-west-1 -s "*" --dataOnly |
| 134 | +dynamodump -m restore -r us-west-1 -s "*" --dataOnly |
127 | 135 | ``` |
128 | 136 |
|
129 | 137 | Dump all table schemas and create the schemas (e.g. creating blank tables in a different AWS account): |
130 | 138 |
|
131 | 139 | ``` |
132 | | -python dynamodump.py -m backup -r us-west-1 -p source_credentials -s "*" --schemaOnly |
| 140 | +dynamodump -m backup -r us-west-1 -p source_credentials -s "*" --schemaOnly |
133 | 141 |
|
134 | | -python dynamodump.py -m restore -r us-west-1 -p destination_credentials -s "*" --schemaOnly |
| 142 | +dynamodump -m restore -r us-west-1 -p destination_credentials -s "*" --schemaOnly |
135 | 143 | ``` |
136 | 144 |
|
137 | 145 | Backup all tables based on AWS tag `key=value` |
138 | 146 |
|
139 | 147 | ``` |
140 | | -python dynamodump.py -p profile -r us-east-1 -m backup -t KEY=VALUE |
| 148 | +dynamodump -p profile -r us-east-1 -m backup -t KEY=VALUE |
141 | 149 | ``` |
142 | 150 |
|
143 | 151 | Backup all tables based on AWS tag, compress and store in specified S3 bucket. |
144 | 152 |
|
145 | 153 | ``` |
146 | | -python dynamodump.py -p profile -r us-east-1 -m backup -a tar -b some_s3_bucket -t TAG_KEY=TAG_VALUE |
| 154 | +dynamodump -p profile -r us-east-1 -m backup -a tar -b some_s3_bucket -t TAG_KEY=TAG_VALUE |
147 | 155 |
|
148 | | -python dynamodump.py -p profile -r us-east-1 -m backup -a zip -b some_s3_bucket -t TAG_KEY=TAG_VALUE |
| 156 | +dynamodump -p profile -r us-east-1 -m backup -a zip -b some_s3_bucket -t TAG_KEY=TAG_VALUE |
149 | 157 | ``` |
150 | 158 |
|
151 | 159 | Restore from S3 bucket to specified destination table |
152 | 160 |
|
153 | 161 | ``` |
154 | 162 | ## source_table identifies archive file in S3 bucket from which backup data is restored |
155 | | -python dynamodump.py -a tar -b some_s3_bucket -m restore -r us-east-1 -p profile -d destination_table -s source_table |
| 163 | +dynamodump -a tar -b some_s3_bucket -m restore -r us-east-1 -p profile -d destination_table -s source_table |
156 | 164 | ``` |
157 | 165 |
|
158 | 166 | ## Local example |
159 | 167 |
|
160 | 168 | The following assumes your local DynamoDB is running on localhost:8000 and is accessible via 'a' as access/secret keys. |
161 | 169 |
|
162 | 170 | ``` |
163 | | -python dynamodump.py -m backup -r local -s testTable --host localhost --port 8000 --accessKey a --secretKey a |
| 171 | +dynamodump -m backup -r local -s testTable --host localhost --port 8000 --accessKey a --secretKey a |
164 | 172 |
|
165 | | -python dynamodump.py -m restore -r local -s testTable --host localhost --port 8000 --accessKey a --secretKey a |
| 173 | +dynamodump -m restore -r local -s testTable --host localhost --port 8000 --accessKey a --secretKey a |
166 | 174 | ``` |
167 | 175 |
|
168 | 176 | Multiple table backup/restore as stated in the AWS examples are also available for local. |
|
0 commit comments