Support all AWS regions

Asked by Krzysztof Szarlej

Hi!

Currently the design of S3 backend doesn't allow for using all available regions which is a bad thing. I reviewed the code and the changes needed to enable multiple regions are really minor.

Here is a minimal version of patch:

++++++
diff --git a/duplicity/backends/_boto_single.py b/duplicity/backends/_boto_single.py
index 0fb40b2..b3e8313 100644
--- a/duplicity/backends/_boto_single.py
+++ b/duplicity/backends/_boto_single.py
@@ -165,6 +165,13 @@ class BotoBackend(duplicity.backend.Backend):
                                         parsed_url.path.lstrip('/')))
         if globals.s3_european_buckets:
             self.my_location = Location.EU
+ elif globals.s3_region:
+ if globals.s3_region == "eu-west-1":
+ self.my_location = "EU"
+ elif globals.s3_region == "us-east-1":
+ self.my_location = ""
+ else:
+ self.my_location = globals.s3_region
         else:
             self.my_location = ''
         self.resetConnection()
diff --git a/duplicity/commandline.py b/duplicity/commandline.py
index 45909ba..ce89a1e 100644
--- a/duplicity/commandline.py
+++ b/duplicity/commandline.py
@@ -527,6 +527,7 @@ def parse_cmdline_options(arglist):
     # Whether to create European buckets (sorry, hard-coded to only
     # support european for now).
     parser.add_option("--s3-european-buckets", action="store_true")
+ parser.add_option("--s3-region", type="string")

     # Whether to use S3 Reduced Redudancy Storage
     parser.add_option("--s3-use-rrs", action="store_true")
diff --git a/duplicity/globals.py b/duplicity/globals.py
index 5882a70..d364fcb 100644
--- a/duplicity/globals.py
+++ b/duplicity/globals.py
@@ -183,6 +183,7 @@ s3_use_new_style = False
 # Whether to create European buckets (sorry, hard-coded to only
 # support european for now).
 s3_european_buckets = False
+s3_region = ""

 # File owner uid keeps number from tar file. Like same option in GNU tar.
 numeric_owner = False
++++++

This is basically all what is needed. And then it can be used like that:
/usr/local/bin/duplicity --s3-use-new-style full /home/ec2-user --s3-region ap-southeast-1 s3://s3.amazonaws.com/s3bucket

Is it possible to include it in duplicity? For now I will use patched version but would be cool if this can be in upstream duplicity!

Question information

Language:
English Edit question
Status:
Expired
For:
Duplicity Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.