Backup on S3 "something went wrong"

I am trying to setup a backup on S3, have used following settings, with positive response at first:

Right after it shows a greyed screen with “Loading” and after a while it comes back with an error message and “Something went wrong. Sorry.”

I have run sudo /root/mailinabox/management/backup.py > ~/logfile.log 2>&1 on a terminal and got following log:
Traceback (innermost last):
File “/usr/bin/duplicity”, line 92, in
with_tempdir(main)
File “/usr/bin/duplicity”, line 75, in with_tempdir
fn()
File “/usr/lib/python3/dist-packages/duplicity/dup_main.py”, line 1555, in main
action = commandline.ProcessCommandLine(sys.argv[1:])
File “/usr/lib/python3/dist-packages/duplicity/commandline.py”, line 1223, in ProcessCommandLine
config.backend = backend.get_backend(args[0])
File “/usr/lib/python3/dist-packages/duplicity/backend.py”, line 223, in get_backend
obj = get_backend_object(url_string)
File “/usr/lib/python3/dist-packages/duplicity/backend.py”, line 209, in get_backend_object
return factory(pu)
File “/usr/lib/python3/dist-packages/duplicity/backends/_boto_single.py”, line 174, in init
self.resetConnection()
File “/usr/lib/python3/dist-packages/duplicity/backends/_boto_single.py”, line 199, in resetConnection
self.bucket = self.conn.create_bucket(self.bucket_name,
File “/usr/local/lib/python3.10/dist-packages/boto/s3/connection.py”, line 618, in create_bucket
response = self.make_request(‘PUT’, bucket_name, headers=headers,
File “/usr/local/lib/python3.10/dist-packages/boto/s3/connection.py”, line 667, in make_request
return super(S3Connection, self).make_request(
File “/usr/local/lib/python3.10/dist-packages/boto/connection.py”, line 1070, in make_request
return self._mexe(http_request, sender, override_num_retries,
File “/usr/local/lib/python3.10/dist-packages/boto/connection.py”, line 1030, in _mexe
raise ex
File “/usr/local/lib/python3.10/dist-packages/boto/connection.py”, line 942, in _mexe
connection.request(request.method, request.path,
File “/usr/lib/python3.10/http/client.py”, line 1283, in request
self._send_request(method, url, body, headers, encode_chunked)
File “/usr/lib/python3.10/http/client.py”, line 1329, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File “/usr/lib/python3.10/http/client.py”, line 1278, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File “/usr/lib/python3.10/http/client.py”, line 1038, in _send_output
self.send(msg)
File “/usr/lib/python3.10/http/client.py”, line 976, in send
self.connect()
File “/usr/lib/python3.10/http/client.py”, line 1448, in connect
super().connect()
File “/usr/lib/python3.10/http/client.py”, line 942, in connect
self.sock = self._create_connection(
File “/usr/lib/python3.10/socket.py”, line 824, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File “/usr/lib/python3.10/socket.py”, line 955, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

Something is wrong with the backup: ERROR 30 gaierror
. Traceback (innermost last):
. File “/usr/bin/duplicity”, line 92, in
. with_tempdir(main)
. File “/usr/bin/duplicity”, line 75, in with_tempdir
. fn()
. File “/usr/lib/python3/dist-packages/duplicity/dup_main.py”, line 1555, in main
. action = commandline.ProcessCommandLine(sys.argv[1:])
. File “/usr/lib/python3/dist-packages/duplicity/commandline.py”, line 1223, in ProcessCommandLine
. config.backend = backend.get_backend(args[0])
. File “/usr/lib/python3/dist-packages/duplicity/backend.py”, line 223, in get_backend
. obj = get_backend_object(url_string)
. File “/usr/lib/python3/dist-packages/duplicity/backend.py”, line 209, in get_backend_object
. return factory(pu)
. File “/usr/lib/python3/dist-packages/duplicity/backends/_boto_single.py”, line 174, in init
. self.resetConnection()
. File “/usr/lib/python3/dist-packages/duplicity/backends/_boto_single.py”, line 199, in resetConnection
. self.bucket = self.conn.create_bucket(self.bucket_name,
. File “/usr/local/lib/python3.10/dist-packages/boto/s3/connection.py”, line 618, in create_bucket
. response = self.make_request(‘PUT’, bucket_name, headers=headers,
. File “/usr/local/lib/python3.10/dist-packages/boto/s3/connection.py”, line 667, in make_request
. return super(S3Connection, self).make_request(
. File “/usr/local/lib/python3.10/dist-packages/boto/connection.py”, line 1070, in make_request
. return self._mexe(http_request, sender, override_num_retries,
. File “/usr/local/lib/python3.10/dist-packages/boto/connection.py”, line 1030, in _mexe
. raise ex
. File “/usr/local/lib/python3.10/dist-packages/boto/connection.py”, line 942, in _mexe
. connection.request(request.method, request.path,
. File “/usr/lib/python3.10/http/client.py”, line 1283, in request
. self._send_request(method, url, body, headers, encode_chunked)
. File “/usr/lib/python3.10/http/client.py”, line 1329, in _send_request
. self.endheaders(body, encode_chunked=encode_chunked)
. File “/usr/lib/python3.10/http/client.py”, line 1278, in endheaders
. self._send_output(message_body, encode_chunked=encode_chunked)
. File “/usr/lib/python3.10/http/client.py”, line 1038, in _send_output
. self.send(msg)
. File “/usr/lib/python3.10/http/client.py”, line 976, in send
. self.connect()
. File “/usr/lib/python3.10/http/client.py”, line 1448, in connect
. super().connect()
. File “/usr/lib/python3.10/http/client.py”, line 942, in connect
. self.sock = self._create_connection(
. File “/usr/lib/python3.10/socket.py”, line 824, in create_connection
. for res in getaddrinfo(host, port, 0, SOCK_STREAM):
. File “/usr/lib/python3.10/socket.py”, line 955, in getaddrinfo
. for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
. socket.gaierror: [Errno -2] Name or service not known
.

I can’t find any easy reason why the socket.gaierror.
Any ideas what can be wrong? I am using MIAB v68 and have not modified anything.

I don’t know if it was the same issue, but I couldn’t get the direct backup to work either with an S3 compatible storage target. I instead setup rcopy sync to copy to my object store after the backup takes place locally on the server with a cron job. Just an option in case you want to cover your back while you debug the direct method.

Hi @BangsKeyboards,

thanks for the suggestion and indeed I have already setup an automatic (crontab) backup with duplicity using:
sudo -E duplicity --encrypt-key $GPG_KEY /home/user-data/mail/mailboxes s3://s3.eu-central-1.amazonaws.com/xxxxxxxx/mail/

what I am not sure about is, how I would recover if all goes wrong, but at least I am backing up directly at this moment.

Thanks.

Update: I have tried to rebuild the shell command generated by the backup.py script, exported the environment variables as needed and run the corresponding command as follows from terminal:
/usr/bin/duplicity full --verbosity warning --no-print-statistics --archive-dir /home/user-data/backup/cache --exclude /home/user-data/backup --volsize 250 --gpg-options ‘–cipher-algo=AES256’ --allow-source-mismatch --s3-endpoint-url https://s3.eu-central-1.amazonaws.com /home/user-data s3://miabxxxxxbackup/mail

still getting the same error socket.gaierror: [Errno -2] Name or service not known as follows:
Traceback (innermost last):
File “/usr/bin/duplicity”, line 92, in
with_tempdir(main)
File “/usr/bin/duplicity”, line 75, in with_tempdir
fn()
File “/usr/lib/python3/dist-packages/duplicity/dup_main.py”, line 1555, in main
action = commandline.ProcessCommandLine(sys.argv[1:])
File “/usr/lib/python3/dist-packages/duplicity/commandline.py”, line 1236, in ProcessCommandLine
backup, local_pathname = set_backend(args[0], args[1])
File “/usr/lib/python3/dist-packages/duplicity/commandline.py”, line 1107, in set_backend
config.backend = backend.get_backend(bend)
File “/usr/lib/python3/dist-packages/duplicity/backend.py”, line 223, in get_backend
obj = get_backend_object(url_string)
File “/usr/lib/python3/dist-packages/duplicity/backend.py”, line 209, in get_backend_object
return factory(pu)
File “/usr/lib/python3/dist-packages/duplicity/backends/_boto_single.py”, line 174, in init
self.resetConnection()
File “/usr/lib/python3/dist-packages/duplicity/backends/_boto_single.py”, line 199, in resetConnection
self.bucket = self.conn.create_bucket(self.bucket_name,
File “/usr/local/lib/python3.10/dist-packages/boto/s3/connection.py”, line 618, in create_bucket
response = self.make_request(‘PUT’, bucket_name, headers=headers,
File “/usr/local/lib/python3.10/dist-packages/boto/s3/connection.py”, line 667, in make_request
return super(S3Connection, self).make_request(
File “/usr/local/lib/python3.10/dist-packages/boto/connection.py”, line 1070, in make_request
return self._mexe(http_request, sender, override_num_retries,
File “/usr/local/lib/python3.10/dist-packages/boto/connection.py”, line 1030, in _mexe
raise ex
File “/usr/local/lib/python3.10/dist-packages/boto/connection.py”, line 942, in _mexe
connection.request(request.method, request.path,
File “/usr/lib/python3.10/http/client.py”, line 1283, in request
self._send_request(method, url, body, headers, encode_chunked)
File “/usr/lib/python3.10/http/client.py”, line 1329, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File “/usr/lib/python3.10/http/client.py”, line 1278, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File “/usr/lib/python3.10/http/client.py”, line 1038, in _send_output
self.send(msg)
File “/usr/lib/python3.10/http/client.py”, line 976, in send
self.connect()
File “/usr/lib/python3.10/http/client.py”, line 1448, in connect
super().connect()
File “/usr/lib/python3.10/http/client.py”, line 942, in connect
self.sock = self._create_connection(
File “/usr/lib/python3.10/socket.py”, line 824, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File “/usr/lib/python3.10/socket.py”, line 955, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

the issue seems to be in the way duplicity is setup. Still investigating. Any help is welcome.

Update: kind of solved!
I have removed duplicity (had version duplicity 0.8.21) and installed version duplicity 2.2.2 February 03, 2024.
This version does not need S3 Host / Endpoint so I have modified the backup.py commenting every *get_duplicity_additional_args(env) out.

Now it is running.

1 Like

This should already be the case by default. What version of MiaB are you on?

I had upgraded MiaB from v67 to v68 on Apr 14. Should I upgrade also other modules (e.g. Duplicity) manually or is it not upgraded with the new version? Just to know how to behave in future.

Thanks.

Version 0.8.21 is from the default Ubuntu repositories. Part of the MiaB installation is to add a duplicity ppa from which a newer version is installed. I’m just surprised this didn’t happen for yours. Or are you using ARM instead of x64?

If you are using arm see the workaround here: Using MIAB On ARM
You have to manually create the link after each update.

OK then that’s the issue: I am running on an Ubuntu t4g.medium EC2 instance on AWS baed on ARM…got the point!
Thanks @KiekerJan and @vele