Advertisement

TUAW Tip: The easy way to backup on mount


Sometimes you have to suffer through the hard way once or twice just to find out... there's an easier way. I've posted recently about commercial backup applications that trigger a backup when you connect a target drive; I've posted on roll-your-own scripts that do the same thing. Over at MacOSXHints, an enterprising soul took the scripts from post #2 and enhanced/extended them. Great effort, everyone!

Then, along comes a comment to the scripting hint: "Hey, why not just use Do Something When?" Gosh, never heard of that, let's check it out... gadzooks! A preference pane that launches an application or document when a drive is mounted! Why, with that plus SuperDuper!, or Automator, or even rsync/rsnapshot and Platypus -- you'd be a backup machine.

So, the way to trigger backups on mount can be summed up thusly:

  1. Create your backup script in your tool of choice and save as a document or applet.

  2. Trigger that script when your drive is mounted, using DSW.

  3. There is no step three. There's no step 3!

See additional notes and caveats after the jump.

Update: As Greg points out in his comment, with any scheduled or triggered clone to a drive, there's the risk of accidentally overwriting your 'good' data if you connect the backup device to recover a file. Be sure to: disable the DSW pane before recovery; hook up your drive to a different machine; use a backup tool that requires a confirmation click (SuperDuper!), or one that does incremental/historical backups (rsnapshot, Chronosync, EMC Retrospect).

Also, Amy's comment points to a Mothership-sanctioned approach: an AppleScript Folder Action to launch when a drive is mounted. Again, the cautions from Greg apply: you run the risk of accidentally overwriting your backup using any auto-launch method, so be careful out there.

[via MacOSXHints]