Copying files with various ownership to samba server

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
afora
Level 4
Level 4
Posts: 203
Joined: Mon Aug 26, 2019 7:35 pm

Copying files with various ownership to samba server

Post 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!
User avatar
Kadaitcha Man
Level 10
Level 10
Posts: 3115
Joined: Mon Aug 27, 2012 10:17 pm

Re: Copying files with various ownership to samba server

Post 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.
It's pronounced kad-eye-cha, not kada-itcha.
Post Reply

Return to “Newbie Questions”