#!/bin/bash # This script verifies the backup drive is mounted, so that # you know it is OK and backups can proceed. The reason is that you # probably don't want to back up files to your on-board drives, so you # only want to run the backups if the external drive is mounted. #### Configuration: Edit the next few lines to set this script up. # # BACKUPSTR: Text to look for that you would see if you run the /bin/mount # command while the drive is mounted (but not if it isn't mounted), such as # the name of the backup directory on the remote device. # BACKUPDIR: Your mount point for the backup drive. # ROOTDIR: Subdirectory of BACKUPDIR where you store / backups. # BOOTDIR: Subdirectory of BACKUPDIR where you store /boot backups. # OPTDIR: Subdirectory of BACKUPDIR where you store /opt backups. BACKUPSTR=YOURTEXT BACKUPDIR=/opt/YOURMOUNTPOINT ROOTDIR=rootbackups BOOTDIR=bootbackups OPTDIR=optbackups #### End of configuration # Check to see if the bakdrive is mounted by verifying that the BACKUPSTR # is part of the output of /bin/mount. if !( /bin/mount | /bin/grep ${BACKUPSTR} > /dev/null 2> /dev/null ) then echo "Backup drive not mounted" exit 1 fi # Check to see that all the backup dirs are there. if !(test -d ${BACKUPDIR}/${ROOTDIR} ) then echo "Backup root dir not there" exit 1 fi if !(test -d ${BACKUPDIR}/${BOOTDIR} ) then echo "Backup boot dir not there" exit 1 fi if !(test -d ${BACKUPDIR}/${OPTDIR} ) then echo "Backup opt dir not there" exit 1 fi # If we get here, all tests passed and we are OK. exit 0