Check network drive availability on Mac

I create a script for myself to automate the backup of certain directories on my mac to airdisk (a USB drive at my extreme airport).

I read about rsync. It seems that if airdisk is not installed, rsync creates a directory in "/ Volumes / drive name".

This can fill up my hard drive, and it should not back up to my local drive. Therefore, I want to check if the installed disk is available before running the rsync command.

Can anyone help?

+3
source share
1 answer

I would see if a file exists in mount. As long as you mount the drive in the same place every time, this should work.

if [ -f /Volumes/AirDisk/foo.txt ];
then
   echo "AirDisk mounted. Starting backup"
   #Put backup script here
else
   echo "File does not exists"
   exit 1
fi
+3
source

All Articles