Using duplicity with minio

Getting duplicity set up to work with minio isn't entirely straightforward.

Starting with minio running locally on port 9000 (or in docker), and using the duplicity command line:

/usr/bin/duplicity --no-encryption --s3-unencrypted-connection ./ s3://minio.dretzq.org.uk:9000/duplicity-test/

Might result in:

NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers 
   were checked. ['S3HmacAuthV4Handler'] Check your credentials

You need to set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.

The next error you might encounter is:

UnboundLocalError: local variable 'region_name' referenced before assignment

This error is caused because the local minio's hostname does not match any of the formats known by the boto library (used by duplicity to talk to S3), so boto can't know which region to use in its S3 API requests or authentication signatures.

I tried setting a bunch of different environment variables to tell boto which region I was running, but in the end the simplest option was to create a hosts alias (or DNS entry) that contains the string s3-<region>, where <region> is the region code that minio was configured with.

This places the correct region identifier into the authentication signature that boto passes to mini.

After that, simple, and runs very fast.!

/usr/bin/duplicity --no-encryption --s3-unencrypted-connection ./ s3://s3-r0.minio.dretzq.org.uk:9000/duplicity-test/