An AppleScript for real time backups with Path Finder

Apr 11, '06 06:40:00AM

Contributed by: e:leaf

If you're like me, you use Path Finder in lieu of Apple's OS X Finder as your primary file browser. This means that the Finder is never running on my system, and I would like for it to not launch each time my backup runs. Previous versions of Path Finder have had abysmal AppleScript support, and although v4 isn't perfect, it has gotten much better. It seems that there are commands which work as they do with the Finder, but for some reason are not listed in its dictionary.

Now, I'm terrible with backing up my system on a regular basis. But I still need for there to be a reliable backup of many of my files. So I set up a folder action to do real-time backups of all of my most needed files using missing dictionary descriptions.

To create a real-time backup system using Path Finder, open Apple's Script Editor and paste in the following code:

on adding folder items to this_folder after receiving added_items
  try
    tell application "Path Finder"
      if exists "/Volumes/path/to/foo" then --insert path to backup volume
        duplicate added_items to "/Volumes/path/to/foo/"  --insert path to specific folder on backup volume
      else
        duplicate added_items to "/Users/path/to/foo"  --create a temporary folder on your hard disk so that you can save manually to backup disk
      end if
    end tell
  end try
end adding folder items to

Save this script as a script in /Library/Scripts/Folder Action Scripts, and then attach it to any folder.

Folder actions perform specific tasks when something has happened to the folder to which an action is attached. For instance, when any item or items are saved to a particular folder, the action will trigger a script. In this case, when the folder has any files saved to it, it will automatically copy these files to a backup drive in real time, as soon as the file(s) is saved.

What the above script does is check to see if my external backup drive is connected. If it is, it copies any items which have been saved (or copied or moved) to the folder to a specified folder on my backup drive. If the drive is not mounted, it copies those files to a temporary folder on my hard disk, so that I can manually copy them to my backup drive later.

It's not a perfect solution, but it works well. I always have the latest files backed up all of the time. And this script should be able to be easily edited, so that the Finder will do this as well.

Comments (6)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20060405001048152