Checking for availability of network disk on mac
I'm creating myself a script to automate the backing up of certain directories on my m开发者_StackOverflowac to an airdisk (usb disk on my airport extreme).
I was reading up about rsync. It seems that if the airdisk isn't mounted, rsync creates the directory in "/Volumes/the name of the disk".
This could fill up my hard drive and it isn't supposed to make the backup on my local drive. Therefore I want to check if the mounted drive is available before I start the rsync command.
Can anyone help?
I would check to see if a file located in the mount exists. As long as you mount the disk in the same location each 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
精彩评论