Mar 19, '09 07:30:00AM • Contributed by: Anonymous
This is very useful for me (versus scheduled backups) because I am at my home and office desks at variable times of the day. When I get to work in the morning, I just connect the drive and away it goes! A few hours later when I leave, I just check Finder to make sure the drive is unmounted and pack up.
Read on for the details.
Note that my script is designed for two different drives; it can be reduced for only one. First, create a shell script to unmount your external drives, and place it in ~/Library/Scripts. For USB disks:
#!/bin/bash
system_profiler SPUSBDataType | grep "BSD Name: disk.$" | \
sed "s/^.*: //" | (while read i; do /usr/sbin/diskutil unmountDisk $i; done)
For Firewire disks, use this script instead:
#!/bin/bash
system_profiler SPFireWireDataType | grep "BSD Name: disk.$" | \
sed "s/^.*: //" | (while read i; do /usr/sbin/diskutil unmountDisk $i; done)
Remember to make these scripts executable (chmod a+x script_name). Next, with the backup drive attached, create an automated, timed backup in SuperDuper that runs the unmount shell script upon completion. Once that's done, copy the Scheduled Setting from ~/Library » Application Support » SuperDuper! » Schedule Copies to ~/Library » Application Support » SuperDuper! » Saved Settings.
In Terminal, create a symbolic link in ~/Library » Scripts to the Copy Job.app inside the Saved Setting package:
Create a new AppleScript called Auto Backup to External Drive with this code (set the top parameters appropriate to your drive or drives): Save this script to the /Library » Scripts » Folder Action Scripts folder. Finally, in the Finder, press Shift-Command-G (Go » Go to Folder) and type /Volumes then press Return. Control-click in a blank area of the Volumes folder and go to More » Attach Folder Action. In the dialog that appears, navigate to and select the Auto Backup to External Drive script you just created.
That's it. To use your new auto-backup script, just plug in your backup drive and wait.
References:
- Mount and unmount FireWire drives via shell script
- Automating backup of Flash drives
- Can I use SuperDuper! 2.0 with my Maxtor OneTouch Button?
- Automator and Folder Actions Tutorial
