How can I automount a shared network drive for Time Machine backups?
At home, my primary computer is an iMac with an external USB hard drive. The external drive is shared so that other computers can use it for Time Machine. I have a MacBook Air that I take to work every day, and it uses the shared Time Machine drive when I am at home. However, I have to manually mount the drive.
How can I set up my MacBook Air to automatically mount the shared drive when I'm on my home AirPort network?
Currently, I perform these steps to mount the shared drive and back up:
- In a Finder window, select the iMac from the Shared list
- Press "Connect"
- Authenticate with my iMac user credentials (I just saved the password to my keychain)
- Choose the USB drive from the list of available volumes to mount
- Use the Time Machine menu extra to choose "Back Up Now"
Ultimately, I want to make this a zero-step process, so I can come home, turn on the MacBook Air, automatically detect and mount the shared drive, and back up with Time Machine. I assume this can be automated, with an automation script set up as a login item, but it would be preferable to avoid explicitly scripting it.
(I originally wanted to attach the hard drive to my AirPort Extreme and share it from there for Time Machine, but this failed or was not allowed on SnowLeopard; I don't remember. I haven't attempted it since upgrading to Lion.)
Thanks for reading!
Both of my computers are running Lion.
I think I can get you started, but using terminal commands, which you said you'd prefer to avoid. Apologies, but it might give you a starting point. All of the following you could put in a bash script and run as a login item.
You'll need to first share out the target drive(s) (MyBook
in the examples below) using file sharing (System Preferences > Sharing > check the File Sharing box, add the drives you need and set appropriate permissions - I just use Everyone to keep it simple).
You can mount a remote machine and/or its associated drives using mount like so:
Make a directory as the mount point (obviously call test
whatever you want):
mkdir /Volumes/test
Now mount the remote drive. I'm assuming this is already connected to your iMac and appears when you connect to your iMac using Finder:
mount -t afp afp://<your mac's name>/<drive name to mount> /Volumes/test
On my remote Mac Mini, to connect to my MyBook attached to it via USB, that would be:
mount -t afp afp://bobs-mac-mini/MyBook /Volumes/test
If you need to authenticate (I got error -5000
when trying to mount my home folder), you can also do this using
mount -t afp afp://<username>:<password>@<your mac's name>/<drive name to mount> /Volumes/test
However, the password would unfortunately have to be in the clear. So again, this might be:
mount -t afp afp://binarybob:password123@bobs-mac-mini/MyBook /Volumes/test
You can also connect to your home folder using the above method, just by replacing MyBook
with the name of your home folder.
The drive you mounted should now appear in the finder and you should be able to use it like any other locally mounted drive. When you're finished, you can do:
umount /Volumes/test
to remove it. BTW, if you're not an administrator, you might need to add sudo
in front of each command and type an administrator password.