Windows (Samba) Share on a Raspberry PI

Assuming you are working  somewhere with a small team and you need a local Windows share to collaborate on documents and oder data. A first choice would obviously be to use Dropbox or a similar cloud service. However if you do not want to send your data to another company or if your internet connection is unstable, you might want to use a server in your local network. My suggestion here is the following: Grab yourself a Rapberry PI, configure a Windows compatible Samba share and start using it.

Preparation

  • Purchase a Raspberry PI 3, a power supply, an SD card and preferably an enclosing.
  • Write the Raspbian image to the SD card and start the PI.
  • Use sudo raspi-config  to set the hostname and enable SSH.

Install Samba

  • Run sudo apt-get install samba samba-common-bin  to install the required packages.
  • Create the folder for the share:  sudo mkdir -m 1777 /share
  • Open /etc/samba/smb.conf  as root (sudo!) using vim or nano (according to your taste of Linux editors and append the following block at the bottom.
  • Restart the samba service: sudo service samba restart

Create Users

Now you can create the accounts that will be able to use the share:

You can now access the share using the hostname or the IP address in your windows explorer: \\ip\share

Configure Backup

Never trust your users not to mess up things. You should not skip doing backups, especially when it is as easy as this:

  1. Edit the crontab file: crontab -e
    Add the following line at the bottom to create a backup every hour from 7 to 22.
  2. Create the backup script: sudo nano /home/pi/run-backup.sh  and add the following content.
  3. Make the script executable:  chmod a+x /home/pi/run-backup.sh

Backups are now created every hour as zip files in the folder  /home/pi/backups/ .

Sources

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.