barman-cloud-backup -h remote: permission errors... local?

83 views
Skip to first unread message

Alessandro Dentella

unread,
Sep 4, 2024, 1:50:24 PM9/4/24
to Barman, Backup and Recovery Manager for PostgreSQL
Hi,

I'm testing barman-cloud-backup. I managed to backup (and restore) local db to my minio S3 storage bu now i wanted to test backup of a remote server and I receive an error that buffles me.

$ barman-cloud-backup -P 4timing -h 4timing.prod.thux.dev -U postgres --endpoint-url https://minio.thux.it s3://4timing-backup 4timing                                                                                                
2024-09-04 19:25:50,869 [2703] ERROR: Backup failed uploading data ([Errno 2] No such file or directory: '/var/lib/postgresql/13/main/global/pg_control')     


Strace confirms that this is a local file that barman-cloud-backup tries to open and fails. So I created it and added permission to barman user (that I'm using). The result is another error:
$ barman-cloud-backup -P 4timing -h 4timing.prod.thux.dev -U postgres --endpoint-url https://minio.thux.it s3://4timing-backup 4timing
2024-09-04 19:24:22,000 [32062] ERROR: Backup failed uploading data ([Errno 2] No such file or directory: '/var/lib/postgresql/13/main/global/pg_control')          
                                                                                       
Exception ignored in: <function _Stream.__del__ at 0x7fa170c10840>
Traceback (most recent call last):
  File "/usr/lib/python3.7/tarfile.py", line 417, in __del__
    self.close()
  File "/usr/lib/python3.7/tarfile.py", line 465, in close
    self.fileobj.write(self.buf)
  File "/usr/lib/python3/dist-packages/barman/cloud.py", line 217, in write
    self.buffer = self._buffer()
  File "/usr/lib/python3.7/tempfile.py", line 702, in NamedTemporaryFile
    (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
  File "/usr/lib/python3.7/tempfile.py", line 397, in _mkstemp_inner
    fd = _os.open(file, flags, 0o600)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/barman-cloud-backup-wd5ayp4v/barman-upload-390wfjp9.part'

My understanding is that barman opens a pg connection and transfers the content from the remote host to local to further upload to S3 and something goes wrong while writing locally. I see no option to set a download directory, the choosen one doesn't seem really appropriate to me (exactly the $PGDATA of std db).

BTW I get the error even if I run the command as root

Did I overlook something or is this a bug?

Does barman-cloud-backup uses the pg connection even when not using option -h? (it so seems looking at the code). If yes why does it work if the pg server is on the same server as the script barman-cloud-backup?

TIA

Martin Marques

unread,
Sep 23, 2024, 3:13:08 AM9/23/24
to pgba...@googlegroups.com
You are supposed to run the `barman-cloud` scripts using the user that
owns the Postgres cluster, typically, the postgres user.

On Wed, 4 Sept 2024 at 19:50, Alessandro Dentella
> --
> --
> You received this message because you are subscribed to the "Barman for PostgreSQL" group.
> To post to this group, send email to pgba...@googlegroups.com
> To unsubscribe from this group, send email to
> pgbarman+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/pgbarman?hl=en?hl=en-GB
>
> ---
> You received this message because you are subscribed to the Google Groups "Barman, Backup and Recovery Manager for PostgreSQL" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pgbarman+u...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/pgbarman/afae9248-fdfe-4cc5-b6e7-d1c389f2c31cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages