SAMBA

Preparation

  1. Create group for backups
sudo groupadd backupusers
  • create new group backupusers
  1. Create user for samba
sudo adduser --disabled-login --no-create-home --gecos "" smbbackup
sudo usermod -aG backupusers smbbackup
  • --disabled-login - no system login
  • --no-create-home - no user home directory
  • --gecos "" - no interactive questions for name and so on
  • with usermod: add user $USER to group backupusers
  1. Prepare directory to use with samba
sudo chown root:smbbackup /srv/ssd/backups
sudo chmod 2770 /srv/ssd/backups
  1. Install samba
sudo apt install samba samba-common-bin smbclient cifs-utils
systemctl status smbd --no-pager
  • last one for checking status of smbd (active?)
  1. Registrate user for samba
sudo smbpasswd -a smbbackup
sudo smbpasswd -e smbbackup
  • first one registrates smbbackup with a chosen password as user in samba
  • second one enables user smbbackup
  1. Change samba configuration
sudo cp /etc/samba/smb.conf "/etc/samba/smb.conf.backup-$(date +%F-%H%M%S)"
sudo nano /etc/samba/smb.conf

add at the end

[Backups]
    comment = Backups auf der externen SSD
    path = /srv/ssd/Backups

    browseable = yes
    read only = no
    guest ok = no

    valid users = smbbackup
    force group = backupusers

    create mask = 0660
    force create mode = 0660
    directory mask = 2770
    force directory mode = 2770
  1. Restart samba
sudo testparm -s
sudo systemctl restart smbd
  • check configuration and then restart
  1. Checks
1
2
3
sudo systemctl status smbd --no-pager
smbclient -L localhost -U smbbackup
smbclient //localhost/Backups -U smbbackup

1: check service active and enabled 2: check Shares of samba 3: connect to shell of samba and test mkdir test

  1. Prepare connection to network
1
2
3
4
sudo ufw app list
sudo ufw app info Samba
sudo ufw allow in on <eth0> from <192.168.2.0/24> to any app Samba
sudo ufw status

1: all apps ufw knows 2: ufw info about Samba app (ports) 3: open ports for LAN in network to Samba 4: show changed ufw rules

On this page
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9