Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions dynamodump.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python
"""
Simple backup and restore script for Amazon DynamoDB using boto to work similarly to mysqldump.

Expand All @@ -15,15 +15,24 @@
import os
import shutil
import threading
import Queue
import datetime
import errno
import sys
import time
import re
import zipfile
import tarfile
import urllib2

try:
from queue import Queue
except ImportError:
from Queue import Queue

try:
from urllib.request import urlopen
from urllib.error import URLError, HTTPError
except ImportError:
from urllib2 import urlopen, URLError, HTTPError

import boto.dynamodb2.layer1
from boto.dynamodb2.exceptions import ProvisionedThroughputExceededException
Expand Down Expand Up @@ -63,13 +72,13 @@ def _get_aws_client(profile, region, service):
# Fallback to querying metadata for region
if not aws_region:
try:
azone = urllib2.urlopen(METADATA_URL + "placement/availability-zone",
data=None, timeout=5).read().decode()
azone = urlopen(METADATA_URL + "placement/availability-zone",
data=None, timeout=5).read().decode()
aws_region = azone[:-1]
except urllib2.URLError:
except URLError:
logging.exception("Timed out connecting to metadata service.\n\n")
sys.exit(1)
except urllib2.HTTPError as e:
except HTTPError as e:
logging.exception("Error determining region used for AWS client. Typo in code?\n\n" +
str(e))
sys.exit(1)
Expand Down Expand Up @@ -913,7 +922,7 @@ def main():
except AttributeError:
# Didn't specify srcTable if we get here

q = Queue.Queue()
q = Queue()
threads = []

for i in range(MAX_NUMBER_BACKUP_WORKERS):
Expand Down