开发者

Checking for availability of network disk on mac

开发者 https://www.devze.com 2023-03-03 18:24 出处:网络
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'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
0

精彩评论

暂无评论...
验证码 换一张
取 消