Page 1 of 1

Copying files with various ownership to samba server

Posted: Mon Jul 27, 2020 8:56 pm
by afora
Yet another samba ownership question.

I'm using a samba server as a backup media by copying local files to a mounted location. My local files is a mix of files owned by both user and root (yes there's some plain text credentials files which are owned by root and have no rwx access to anybody else, such as for example mysql credentials file. Unfortunately when I copy those files over to the server, any root ownership gets reset to the user which is specified in smb.conf file. Hence, those files are now visible to anybody on the server.

I conceptually struggling how to fix this (i.e. keep file ownership and permissions per original file attributes on copy to the server), as my understanding is that Samba would treat all file attributes equal and the same.

Any hints on if it's even achievable? And if not, how do I backup those sensitive files to a Samba share?

Many thanks!

Re: Copying files with various ownership to samba server

Posted: Mon Jul 27, 2020 9:14 pm
by Kadaitcha Man
afora wrote:
Mon Jul 27, 2020 8:56 pm
Any hints on if it's even achievable? And if not, how do I backup those sensitive files to a Samba share?
SMB is essentially a Windows protocol so it doesn't know a single thing about linux filesystem permissions. The only way to preserve the linux permissions is to stuff the files into an archive such as tar.gz before moving them to an SMB share.