Added script to check OS. Modified backup logic to look for mount dir based on OS

This commit is contained in:
Tracey Clark 2020-03-14 21:02:44 -05:00
commit c8aff9beec
2 changed files with 25 additions and 1 deletions

6
check_os.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
# Check what OS we're on
OS=`awk -F = '/^NAME/{print $2}' /etc/os-release`
echo "OS found in /etc/os-release is $OS"
export OS="$OS"

View file

@ -3,11 +3,29 @@
#Script to back up /home/tracey to external USB drive
#http://www.bobulous.org.uk/misc/rsync-backup.html
date=`date +%Y-%m-%d`
mount_point='/media/tracey/Backup'
log_file='/home/tracey/backuplogs/usb-rsync-backup-'${date}'.txt'
echo "#####"
echo ""
# Check what OS we're on
# OS=`awk -F = '/NAME/{print $2}' /etc/os-release`
# echo "OS we're running on is $OS"
source ~/git/shell-scripts/check_os.sh
if [[ "$OS" =~ .*Solus.* ]]
then
echo "Setting mount point for Solus"
mount_point='/run/media/tracey/Backup'
elif [[ "$OS" = "Ubuntu" ]]
then
echo "Setting mount point for Ubuntu"
mount_point='/media/tracey/Backup'
else
echo "Unknown OS!"
fi
echo "Mount point is $mount_point"
# Check whether target volume is mounted, and mount it if not.
if ! mountpoint -q ${mount_point}/; then
echo "Mounting the external USB drive."