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.
[share] Comment = PI Share Path = /share Browseable = yes Writeable = Yes only guest = no create mask = 0777 directory mask = 0777 Public = yes
- Restart the samba service: sudo service samba restart
Create Users
Now you can create the accounts that will be able to use the share:
sudo adduser --no-create-home --disabled-password --disabled-login newuser sudo smbpasswd -a newuser sudo service smbd force-reload
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:
- Edit the crontab file: crontab -e
Add the following line at the bottom to create a backup every hour from 7 to 22.0 7-22 * * * /home/pi/run-backup.sh
- Create the backup script: sudo nano /home/pi/run-backup.sh and add the following content.
FILES="/share/" FOLDER="/home/pi/backups" echo "starting backup of $FILES to $FOLDER" zip -r $FOLDER/share-backup-$(date +"%Y%m%d-%H%M").zip "$FILES" # delete backups older than 3 days find $FOLDER -type f -mtime +3 -delete echo "finished backup"
- 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/ .