Skip to content

RemoteServerSambaConfig

Luca Finzi Contini edited this page Oct 21, 2024 · 8 revisions

Remote Server Samba Configuration

On the remote server we want these features

  1. Normal Samba folders of our backed up data;
  2. The Samba backup folders shall be READ ONLY: we do not want to modify our backups, otherwise... they would not be backups anymore :)
  3. We want to be able to see all our snapshots through Windows' Previous versions, as this screenshot:

Remote Samba Previous Versions

Here is the configuration file /etc/samba/smb.conf :

[global]
workgroup = WORKGROUP
netbios name = BACKUP
wins support = 1
log level = 1
max log size = 1000
read only = no
server string = %h, the COOLEST ZFS backup server ever
security = USER
smb passwd file = /etc/samba/smbpasswd
encrypt passwords = YES
max protocol = SMB3
min protocol = SMB3

[DocumentsBackup]
comment = ZFS mirrored disks vdev Documents folder backup
path=/mnt/storage/DocumentsBackup
valid users = buser
read only = yes
vfs objects = shadow_copy2
shadow:localtime = yes
shadow:format = %Y.%m.%d-%H.%M.%S
shadow:sort = desc
shadow:basedir = /mnt/storage/DocumentsBackup
shadow:snapdir = /mnt/storage/DocumentsBackup/.zfs/snapshot

Please note that in this file the stanza is named after the destination filesystem DocumentsBackup. The real magic starts with the vfs object line, which uses this shadow_copy2 plugin, and the following lines describe where to find the snapshots that will be exposed in the Windows Previous Versions window.

Then we enable the buser user as a Samba user with smbpasswd:

buser@backup:/etc/samba$ sudo smbpasswd -a buser
lpcfg_do_global_parameter: WARNING: The "encrypt passwords" option is deprecated
New SMB password:
Retype new SMB password:
Added user buser.
buser@backup:/etc/samba$
buser@backup:/etc/samba$ sudo service smbd restart
buser@backup:/etc/samba$ sudo service nmbd restart
buser@backup:/etc/samba$

Now let's check on Windows:

  • open Windows Explorer and go to \\backup
  • Windows will ask you for username and password; type buser as user and the password you just inserted in the previous smbpasswd command;
  • The fresh DocumentsBackup share will be displayed. Right-Click on it and select Previous Versions, and, lo and behold: Backup Server with Samba and Previous Versions is WORKING!
  • Try to open a file from the Samba backup data: Backup Server: opening a file from Windows via Samba Share
  • The backup data is set to read only: verify this by trying to delete a file from Windows. You will obtain a 'permission' problem like this: Backup Server: trying to delete a file returns error

That's the main workings of the system.

I believe it is pretty awesome.

What do you think about it?

Enough bragging, let's continue with normal backup operations.

Clone this wiki locally