Is there a simple method to automatically reconnect a network drive that has been disconnected due to network failure or some other issue. I have a batch job setup that periodically copies files to a network drive, when the drive disconnects, I need to manually remount the drive.
Answer
Add some code to check for the mounts and to try and remount them if needed - here's some (snipped bits) from a Linux backup bash script (sorry, no OSX to hand at the moment) - it might give you some pointers and maybe someone will post an OSX equivalent too:
thishost='myhostname'
#
mountpoint='/root/mybackup'
#
mountoptions='-o username=bkuplinux,domain=mydomain,password=mypassword'
#
sharename='//ssc4/linux'
#
emailtarget='myemail@address.com'
###################################
# End of user editable variables
###################################
backupfolder=$mountpoint/$thishost
if [ $(mount | grep -c $mountpoint) != 1 ]; then
echo "$mountpoint mount is not present - trying to mount..."
mount -t cifs $sharename $mountpoint $mountoptions
if [ $(mount | grep -c $mountpoint) != 1 ]; then
echo "$mountpoint mount is still not present - quitting"
if [ "$emailtarget" != "" ]; then
echo "$mountpoint mount is not present on $thishost so backup cannot continue" | mail -s "$thishost backup problem" $emailtarget
fi
exit 1
fi
fi
No comments:
Post a Comment