Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use a run-on-drive-connect SuperDuper backup script Apps
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:
#!/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: [robg adds: I haven't tested this one yet, but I intend to, as it seems perfect for my once-daily boot drive clone task. Note, too, that that unmount scripts will unmount all attached USB (or FireWire) drives. If you just want to unmount one drive, you'll need to modify the code to unmount just that one drive. I worked out a replacement script that should work for just one drive, attached via FireWire or USB; here's what I came up with as the executable line:
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.]
    •    
  • Currently 1.71 / 5
  You rated: 2 / 5 (7 votes cast)
 
[19,538 views]  

Use a run-on-drive-connect SuperDuper backup script | 8 comments | Create New Account
Click here to return to the 'Use a run-on-drive-connect SuperDuper backup script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use a run-on-drive-connect SuperDuper backup script
Authored by: Coumerelli on Mar 19, '09 07:52:29AM

5 stars for this baby!

---
"The best way to accelerate a PC is 9.8 m/s2"



[ Reply to This | # ]
Use a run-on-drive-connect SuperDuper backup script
Authored by: NovaScotian on Mar 19, '09 08:10:37AM

Wouldn't a launchd agent watching /Volumes do as well? It could trigger an AppleScript to identify any "new" disk (the agent will trigger for any drive that mounts) and if it is the backup disk run the AppleScript to start the backup and then dismount the drive.



[ Reply to This | # ]
Use a run-on-drive-connect SuperDuper backup script
Authored by: gm80 on Mar 19, '09 08:27:38AM
Or you could accomplish the same thing through the GUI using the fantastic DoSomethingWhen preference pane.

Set up a rule: When [volumename] Mounts, Run [symlink to SD script].

As long as the SD backup is set to automatically close on completion you can set up another rule: When [SuperDuper] Quits, Unmount [volumename].

Done it for a couple of years now and it works beautifully.

[ Reply to This | # ]

Use a run-on-drive-connect SuperDuper backup script
Authored by: kgp on Mar 28, '09 06:25:11AM

I am having trouble setting up Superduper and DSW. Would you flesh out some of the details like setting up the script in Superduper for a beginner please?
Thanks!



[ Reply to This | # ]
Use a run-on-drive-connect SuperDuper backup script
Authored by: kgp on Mar 28, '09 05:08:24PM
I seem to have figured it out by using information from this link http://www.shirt-pocket.com/forums/showthread.php?t=993

Great hint thank you very much.

[ Reply to This | # ]
Use a run-on-drive-connect SuperDuper backup script
Authored by: hamarkus on Mar 19, '09 02:03:17PM

Synk (decimus.net) can do this out-of-the-box, sans the un-mounting.
(Just a happy customer who uses both Synk and SuperDuper, not wanting to put all eggs into one basket.)



[ Reply to This | # ]
Use a run-on-drive-connect SuperDuper backup script
Authored by: andersmoldin on Mar 27, '09 01:30:52AM

I got stuck on "Next, with the backup drive attached, create an automated, timed backup in SuperDuper that runs the unmount shell script upon completion.". Could you be a little more precise? Should I click the "Schedule..." button and create an automatic backup there? With what settings?



[ Reply to This | # ]
Use a run-on-drive-connect SuperDuper backup script
Authored by: oik on Mar 27, '09 09:46:54AM

Hi, I'm the author of this tip... sorry about that big step there. Here's some more details.

- Open SuperDuper!
- Select the drives to Copy FROM and TO
- Select "Using" whichever method you want (I use Backup -- all files for one big drive and Backup -- user files for another drive)
- Click Options...
- On Advanced, click "Run shell script after copy completes" and select the Unmount USB / Firewire script that you made earlier
- Click OK
- Click Schedule...
- Create any schedule as long as "Automatically copy" is selected at top. Don't worry about the actual schedule much because you're just trying to create a packaged file with the settings all saved.
- Click OK
- Close out SuperDuper!

Let me know if you need any more help getting this going.



[ Reply to This | # ]