#!/bin/sh
datum=$(date +%d_%m_%y)
source=$(hostname)
# Create local share point
mkdir -p ~/RPI_Backups
# Mount the remote backup folder
sudo mount -t cifs -o rw,guest,vers=3.0 //myserver.local/myshare/myfolder ~/RPI_Backups
# Create a subfolder for this host
sudo mkdir -p ~/RPI_Backups/$source
# Create the backup with tar, excluding the backup folder itself
sudo tar --warning=no-file-changed \
--exclude=/home/pi/RPI_Backups \
-czvf /home/pi/RPI_Backups/$source/home_backup_$datum.tar.gz /home/pi
# Unmount the remote share
sudo umount ~/RPI_Backups