TrueNas Backup script

This is a script, that will copy selected folders from TrueNas Server to an external USB disk – for creating an offline backup of the data. The credentials are stored in the file /etc/local/msmtprc

#!/bin/sh
#
# This script copy backupSTOR1=’/mnt/data/veeam’
STOR2=’/mnt/USB’
LOG=’/tmp/backup.log’# Starting the scripts
# Test if USB is created
if [ -d “$STOR2” ]; then
echo “Folder $STOR2 exist …” >> $LOG
else
echo “No $STOR2 folder exist” >> $LOG
exit
fi

# Copying the data
echo “Starting copying the data from Truenas to USB” >> $LOG
cp -Rf “$STOR1/DMZ” $STOR2/
cp -Rf “$STOR1/LinuxServers” $STOR2/
cp -Rf “$STOR1/WINDOWS” $STOR2/
cp -Rf “$STOR1/MT-PFsense” $STOR2/
cp -Rf “$STOR1/VeeamConfigBackup” $STOR2/

echo “Finished backing up the data” >> $LOG
# Sending email as information
/usr/local/bin/msmtp –file=${msmtp_config:-“/etc/local/msmtprc”} TEST@EXAMPLE.com < /tmp/backup.log
# Finishing the script – delete /tmp files
rm -rf $LOG
#EOF