PurpleSync

April 29, 2008

Here’s a pretty neat little AppleScript (did I just say that?!) for backing up random bits of your home folder. Just flag anything with the Purple Label in the Finder and PurpleSync will pick it up and back it up to a destination of your choosing, which it will prompt for only once (delete the pref file to reset).

If you only have Apple’s rsync (2.6.3), then this will unfortunately butcher the extended attributes (like the label) and ACLs, since it does not understand the -X and -A arguments. Version 3.0 from MacPorts works better.

I kinda like the idea that, instead of defining stuff that I don’t want backed up (ala TimeMachine), I just label the ones I do. Labels are very easy to use and audit and don’t require special software.

The script itself is a whopping 11 lines long:

set dst to ""
set homedir to POSIX path of (path to home folder)

try
    set dst to do shell script "defaults read " & homedir & "/Library/Preferences/com.firstpartysoftware.purplesync syncDestination"
on error
    set dst to quoted form of POSIX path of (choose folder)
    do shell script "defaults write " & homedir & "/Library/Preferences/com.firstpartysoftware.purplesync syncDestination " & dst
end try

do shell script "rsync -paz  --delete --exclude=" & dst & " $(mdfind -onlyin " & homedir & " kMDItemFSLabel=3) " & dst

Stick it into iCal to have it run automagically.