Mac OS X

Maestro Monday: Backup OS X Contacts

This week’s Maestro macro is entirely self-contained, no Apple Script or external utilities needed. The macro exports the OS X Contact list (aka Address Book) to a file that can be imported later if it’s needed. The two restrictions are that the screen cannot be locked when the script runs and it can only be run once per day. The macro runs on Mavericks, it may need to be changed for earlier versions (for example, when “Contacts” was called “Address Book”).

I set this macro to be triggered only from the status menu. I have a regular weekly backup routine and run it at that time. While I prefer automated backup solutions, having to be at the computer to trigger isn’t a problem in this case. My weekly routing includes making sure the backups ran OK and this one runs so quickly it adds almost no time to how long it would take to verify the backup. Plus if I make a lot of changes I can easily do an immediate backup.

This script is one of the longer ones when measured by screen real estate. The process is straight-forward: Start contacts if needed, export the contacts using the export menu, change the location to where I want it and save the file, then quit contacts. There are some pauses in there to give the app time to respond.

The export command automatically includes the date in the file name so the file will have a unique name every day. If the macro is run twice in one day it will break. It will prompt to replace the file and the remaining shutdown command will be lost. This hasn’t been a problem for me so I haven’t taken the time to create a workaround.

Screen capture of macro to backup OS X contacts

Mac OS X

Maestro Monday: Unmount Backup Drive

Last week I shared my macro for automatically mounting drives. This one also deals with drives but this time is to unmount (disconnect them).

I use SuperDuper! to clone my drives to an external USB drive as a bootable backup. SuperDuper! can schedule a backup to occur when a drive is connected to the Mac. But this leaves the USB drive mounted when the backup finishes. I wanted to completely automate the process so all I had to do was connect the USB drive to start and disconnect it when it was done.

To do this SuperDuper! must be configured to quit when the backup is done.

Screenshot of SuperDuper settings

A short Apple Script is also needed for this and will be the following script with “BackupDrive” replaced with the external drive name as it appears in the Finder sidebar.

tell application "Finder"
    eject "BackupDrive"
end tell

I have one script that covers all my Macs and all the external drives I use for backups. The script unmounts any drives it find mounted when SuperDuper quits.

Here’s the Keyboard Maestro script.

The Keyboard Maestro script


Mac OS X

Maestro Monday: (Re)Mount Drives

Keyboard Maestro is fairly new to me but I’ve already put it to good use. One annoyance I had is having to remount server drives. Sure, I could automatically mount them at login but the connection could be lost, such as when the server rebooted. Enter Keyboard Maestro. I have a script that runs when I logon, when I select it from the menu, and every hour if I’m logged on.

A small bit of Apple Script is needed to actually mount (connect to) the drives. The address for the drive is also needed. I use SMB for the connections rather than AFP (Apple Filing Protocol) but the procedure for getting the connection string is the same, it will just look different than the screenshots. The screenshots are from OS X 10.9.2 Mavericks and Keyboard Maestro 6.4.1. It doesn’t really matter, but my “Server” drives are on a Windows Home Server 2011 box and a Synology NAS.

To get the connection mount the drive manually then do a “Get Info” in Finder. Get the “Server” information under general information.

Since the Apple Script does the real work I could use other utilities or schedulers. But Keyboard Maestro seems like a good place to centralize this and it makes it easy to create the logic.

screenshot of the Get Info screen for the drive

The snippet of Apple Script is shown below along with the info from above:

tell application "Finder"
        mount volume "smb://user@osqwhs02/Archive"
    end try
end tell

Note that the user name has to be added to the mount volume command as shown by user@ in the above example. My password is saved in the Mac’s keychain otherwise it would need to be included in the Apple Script.

All this gets put together in a Keyboard Maestro macro:

Keyboard Maestro macro to mount drives

The macro checks to see if the drive is mounted and if it is not then it runs the Apple Script.