If you want to make a SMB share on a server where each machine has different directories, you can set this up with the following config in smb.conf
:
[Backups]
comment = Machine-specific backups
root preexec = install -o "%U" -g storage -m 0751 -d "/srv/data/%m"
path = /srv/data/%m
writeable = yes
create mode = 0600
directory mode = 0700
force directory mode = 0700
force create mode = 0600
which translates to:
- user can access share ‘Backups’
- on access, a machine-specific directory is created if it doesn’t exist, with owner $USER, group storage, permissions 0751 and located in
/srv/data/<machine name>
. - User can access the newly-created directory and shove the backups from this machine in there.
All steps verifiably work, I can ssh into the server and see the new directory with the correct owner and permissions.
When you access the ‘Backups’ share from different machines, they all get their own space within a properly-named dir, without the need to rename different configs of the same program on different machines.
Now y’all ask why did this guy post something so specific? Easy. It was a question first, but this forum is a perfect rubber duck for development by rubber duckie. Each of you can say ‘quack’ now.
I managed to solve my problem while testing it out for this post, and I didn’t want the effort go to waste.