Use a run-on-drive-connect SuperDuper backup script
Thu, Mar 19 2009 at 7:30AM PDT • Contributed by: Anonymous
Thu, Mar 19 2009 at 7:30AM PDT • Contributed by: Anonymous
I've put together information from several other guides (see references at the end) that I found around the web to create an auto-run SuperDuper backup script. The backup will start when you attach a USB (or FireWire) drive, and the drive is then automatically un-mounted when the backup is complete.
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:
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:
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:
sudo ln -s "/Users/your_user/Library/Application Support/SuperDuper!/Saved Settings/Smart Update OfficeDrive from MacHD.sdsp/Copy Job.app" "Smart Update OfficeBackup"
Repeat these steps (create scheduled backup, copy scheduled settings, link to the Copy Job app) for every drive that you want to back up -- just remember to use a new name for each symbolic link.
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
diskutil list | grep name_of_volume | cut -c 69-73 | (while read i; do /usr/sbin/diskutil unmountDisk $i; done)
You'd need to verify that the cut columns are correct on your machine -- do that by leaving off everything after 73 and checking the output shows the full disknn name -- and replace name_of_volume with the name of the volume (disk) you'd like to eject. This bit of code worked in my testing, but proceed at your own risk.]
•
[11,446 views]
