
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:
- Create your backup script in your tool of choice and save as a document or applet.
- Trigger that script when your drive is mounted, using DSW.
- There is no step three. There's no step 3!
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]













Reader Comments (Page 1 of 1)
1-12-2007 @ 7:40AM
Pete White said...
What do people normally backup to? I use another hard drive, can you get tape drives for macs?
Reply
1-12-2007 @ 8:04AM
WÏ??7?¥ said...
All this automatism seems so neat, but what happens, when you have to boot from your Backupdrive? I don’t trust any of this.
Reply
1-12-2007 @ 9:40AM
Mike Rose said...
Pete: Most home users would go with hard drives, DVD or flash. You can use tape drives on the Mac, but there are relatively few that connect via FireWire (LaCie used to sell one, not sure they still do).
#2: SuperDuper! creates reliable, bootable backups; the 'ditto' command should as well, and EMC Retrospect usually does. For other utilities your mileage may vary.
Greg: EXCELLENT point about accidental overwrites of your backup data, I shall amend the post.
Reply
1-12-2007 @ 10:02AM
alangenh said...
So far I've just used Apple's suggested way, Folder Actions, to lauch what I want when a drive is mounted...
http://www.apple.com/applescript/folderactions/05.html
(example 2)
Reply
1-12-2007 @ 10:52AM
ross said...
how i do it is:
I have a powermac upstairs with a shared drive. A macbook pro downstairs connected via wireless. on boot the shared drive mounts. I have two scripts written - one which backups important files i.e. Pictures and Documents folder, and a second script which is a restore script. Both scripts were created through Automater
Very handy...
Reply
1-12-2007 @ 12:16PM
Greg said...
I thought this was a great idea. Until I remembered that the last time I connected my backup drive was to retrieve a file I had edited badly and needed to return to the earlier version. If my backup started automatically it would have replaced the file I was looking for with the newly wrecked file.
Reply
1-18-2007 @ 2:27PM
Marc said...
Where can I get a copy of the SuperDuper Backup Script?
Thanks so much!
Reply