Duplicity S3: Error when calling the HeadBucket operation

I'm trying to get Duplicity to work with OVHcloud's S3 offering.
I've set up an S3 container, and it works when I use "s3cmd":

me@pc ~]$ s3cmd ls
2023-05-07 16:02 s3://backupcontainer-pc

However, when using [duplicity
(version 1.2.2), I run into an error:

File "/usr/lib/python3.11/site-packages/botocore/client.py", line 960, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (400) when calling the HeadBucket operation: Bad Request

This is the command I use (altough I add many more --include/–exclude parameters):

duplicity --verbosity Debug --no-print-statistics --include /usr/local --include /root --exclude ** --asynchronous-upload --s3-region-name WAW --s3-endpoint-url https://s3.waw.io.cloud.ovh.net / s3://backupcontainer-pc

When running the command, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set using the same values which work with s3cmd.

Any ideas?

In the Duplicity mailing list, a solution was found for this: I should have put the region code in lower case, see the "OVHCloud's S3" thread here:
https://lists.nongnu.org/archive/html/duplicity-talk/2023-05/threads.html

The HeadBucket error in Duplicity with OVH S3 usually comes from incorrect S3 configuration rather than a real bucket issue.

With OVHcloud Object Storage, you must use the correct S3 endpoint + region, otherwise the HeadBucket request fails with errors like Bad Request or similar. This happens because OVH’s S3 is compatible, but not identical to AWS defaults.

Common causes & fixes:

  • Wrong endpoint → use format like:
    https://s3.<region>.io.cloud.ovh.net
  • Incorrect region name → make sure it matches your OVH region (e.g., GRA, WAW, etc.)
  • Missing endpoint override → Duplicity/AWS SDK may try AWS instead of OVH
  • Signature/version mismatch → ensure your tool supports S3 v4 signing

Working approach:
Configure Duplicity with both:

  • --s3-endpoint-url (OVH endpoint)
  • correct --s3-region-name