diff --git a/CHANGELOG.md b/CHANGELOG.md index 837a9fd9..cb58c0c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Package updates: Control panel: +* Allow setting the backup location's S3 region name for non-AWS S3-compatible backup hosts. * Control panel pages can be opened in a new tab/window and bookmarked and browser history navigation now works. * Add a Copy button to put the rsync backup public key on clipboard. * Allow secondary DNS xfr: items added in the control panel to be hostnames too. diff --git a/management/backup.py b/management/backup.py index 99c3d60e..06285ba5 100755 --- a/management/backup.py +++ b/management/backup.py @@ -202,7 +202,9 @@ def get_duplicity_target_url(config): # the target URL must be the bucket name. The hostname is passed # via get_duplicity_additional_args. Move the first part of the # path (the bucket name) into the hostname URL component, and leave - # the rest for the path. + # the rest for the path. (The S3 region name is also stored in the + # hostname part of the URL, in the username portion, which we also + # have to drop here). target[1], target[2] = target[2].lstrip('/').split('/', 1) target = urlunsplit(target) @@ -230,10 +232,15 @@ def get_duplicity_additional_args(env): ] elif get_target_type(config) == 's3': # See note about hostname in get_duplicity_target_url. + # The region name, which is required by some non-AWS endpoints, + # is saved inside the username portion of the URL. from urllib.parse import urlsplit, urlunsplit target = urlsplit(config["target"]) - endpoint_url = urlunsplit(("https", target.netloc, '', '', '')) - return ["--s3-endpoint-url", endpoint_url] + endpoint_url = urlunsplit(("https", target.hostname, '', '', '')) + args = ["--s3-endpoint-url", endpoint_url] + if target.username: # region name is stuffed here + args += ["--s3-region-name", target.username] + return args return [] diff --git a/management/templates/system-backup.html b/management/templates/system-backup.html index 422b2a0e..f7305518 100644 --- a/management/templates/system-backup.html +++ b/management/templates/system-backup.html @@ -5,7 +5,7 @@
The box makes an incremental backup each night. By default the backup is stored on the machine itself, but you can also store it on S3-compatible services like Amazon Web Services (AWS).
+The box makes an incremental backup each night. You can store the backup on any Amazone Web Services S3-compatible service, or other options.