egscripts/egrdbackup-usb/initial.sh.example-usb

34 lines
760 B
Text
Executable file

#/bin/bash
#
# This script runs before the main rdiffbackup script
# useful for mounting USB drives
#
#
#
POSSIBLE_USB_DRIVES="/dev/sdc1 /dev/sdd1"
MOUNT_POINT="/mnt"
USB_DRIVE=""
#
#
for i in $POSSIBLE_USB_DRIVES
do
if udevinfo --query=name --name $i
then
USB_DRIVE=$i
fi
done
if [ $USB_DRIVE"xxx" == "xxx" -o $MOUNT_POINT"xxx" == "xxx" ]
then
echo "ERROR - Mount point or drive device not defined in config file or drive device not found" >> $LOGFILE 2>> $LOGFILE
fi
#
if ! mount | grep $USB_DRIVE > /dev/null
then
if ! mount $USB_DRIVE $MOUNT_POINT
then
echo "ERROR - Couldn't mount USB Drive" >> $LOGFILE 2>> $LOGFILE
exit 1
fi
else
echo "WARNING - $USB_DRIVE already mounted" >> $LOGFILE 2>> $LOGFILE
fi