Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Barman (on Linux) fails to back up Windows system with tablespaces to CIFS share on Windows host #891

Open
einhverfr opened this issue Jan 25, 2024 · 2 comments

Comments

@einhverfr
Copy link

einhverfr commented Jan 25, 2024

Situation is that a user has PostgreSQL on Windows with a significant amount of data on a tablespace on the F drive. Barman is running on Ubuntu Focal with /var/lib/barman/[server] mounted as a CIFS share from a Windows file server.

Barman works, and can stream wals to the backup. However creating a backup fails.

The reason is that the tablespace mapping just appends the path to the destination path, providing a path like:
/var/lib/barman/pg/base/20240124T132339/data/F:\postgres\data

This cannot work because the colon (:) has special meaning on NTFS/Windows file paths as a selector for alternate data streams for a given file. If you are not familiar with this feature of NTFS, here's a quick primer including security implications: https://blog.netwrix.com/2022/12/16/alternate_data_stream/

I also assume but am not 100% sure that the changes in slashes do work on Python in this way. I am not sure about pg_basebackup though.

Proposed resolution:

If the barman_home starts with / and the tablespace directory starts with [A-Z]:\ then:
change the mapper to __windows__/[A-Z]/ and drop the colon.
Optionally we may need to also transpose \ to / in order to normalize the paths.

@einhverfr
Copy link
Author

another option would be to allow a custom tablespace map to be provided in the configuration.

@einhverfr
Copy link
Author

As a note, while this issue only is unavoidable with CIFS shares, the problem will surface in other forms if NFS 4.1 is used against a Windows server as the underlying issue is found int he filesystem. Additionally workarounds for the issue in NFS 3 Server for Windows are brittle and difficult to implement perfectly. This would be very nice to fix and it might make it easier to eventually support Windows hosts for Barman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant