The Rules
  • Feel free to leave constructive criticism, or point out a better way to do something.
  • Personal attacks or flames, on me or anyone else, will be deleted.
  • Past history has shown that 99% of comments I can't read (i.e. those in other languages) to be spam. Therefore, any comment I can't read will be removed.
  • I'm pretty mellow concerning profanity, but excessive (as determined subjectively by me), bad language will be removed.

Friday, March 5, 2010

Backup Now, Please.

I realize it's been over a year since my last post, and I have a bunch of stuff stacked up. But this was pretty slick and frankly, I don't want to lose it. So here goes.

The problem: Oftentimes when I'm working on a project, being the hard-drive-paranoid-soul that I am, as I finish a milestone I'll run a Time Machine backup, and also sometimes rsync my project directory to Dropbox. However, it annoys me to shift to the mouse/trackpad to run the time-machine backup, then switch to the Terminal to run the rsync backup.

The solution: A decidedly love-sided instance of my love-hate relationship with AppleScript

do shell script "/System/Library/CoreServices/backupd.bundle/Contents/Resources/backupd-helper >/dev/null 2>&1 &"

property nullStr : ""
set defaultSrc to "/path/to/project/dir"
set defaultDest to "/path/to/destination/dir/in/Dropbox"

--- cancel actions from either of these dialogs will effectively cancel the script
set dropBoxSource to text returned of (display dialog "Dropbox backup source?" default answer defaultSrc)
set dropBoxDest to text returned of (display dialog "Dropbox backup destination?" default answer defaultDest)

if dropBoxSource is not equal to "" and dropBoxDest is not equal to "" then
set rsyncCmd to "rsync -rav " & dropBoxSource & " " & dropBoxDest
display dialog ("Run: '" & rsyncCmd & "'")
--- if the user cancels the dialog here, the rsync won't run. this is just what we want :)

--- set a 2-hour timeout for the rsync command
with timeout of 7200 seconds
do shell script rsyncCmd
end timeout
end if

I saved this applescript as an application, which I can then invoke via spotlight/Quicksilver/Alfred etc, thus removing the problem of hunting for the Time Machine menu.


The shell script that runs the Time Machine backup is a non-documented, non-supported, run-at-your-own-risk solution. It works for me, but I'm making absolutely no guarantees that it won't break something. For that matter, you ought to know what rsync does before feeling too comfy with the rsync backup either.


Alex said...

All right, folks. Remember: if I can't read your comment (i.e. it's not in English) I'll delete it.

Vityleyev said...


Translation: language fascist!