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

An AppleScript for real time backups with Path Finder Apps
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.
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[7,009 views]  

An AppleScript for real time backups with Path Finder | 6 comments | Create New Account
Click here to return to the 'An AppleScript for real time backups with Path Finder' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript for real time backups with Path Finder
Authored by: Synchro on Apr 11, '06 10:03:44AM

While it seems like a nice way of tagging things for backup, wouldn't it be a better idea to use something like rsync to do the actual copies? It should be much faster, and will also 'catch up' if the script happened to miss anything, and it will copy files that changed instead of just ones that have been added.



[ Reply to This | # ]
An AppleScript for real time backups with Path Finder
Authored by: zeusr on Apr 11, '06 06:38:13PM

You can use launchd in combination with rsync, and just have rsync copy whenever something is changed in that folder. I use Lingon and RsyncX as the GUIs (when I don't want to remember the command line stuff).



[ Reply to This | # ]
An AppleScript for real time backups with Path Finder
Authored by: e:leaf on Apr 12, '06 11:51:15PM

I have found a way to do it via rsync (after a bit of time in the man pages of course).

Here we go . . .


on adding folder items to this_folder after receiving added_items
	try
		tell application "Path Finder"
			if exists "/Volumes/path/to/backup/volume" then
				do shell script "/usr/bin/rsync -a --delete --delete-after /path/to/source/directory/ /Volumes/path/to backup/directory"
			end if
		end tell
	end try
end adding folder items to

Using rsync actually synchronizes the source and backup folder (the destination folder will look exactly like the source folder after the script runs) rathr than simply copying files from one folder to the next. You can also set up rsync to do a backup of any files which are deleted from the destination folder in the event that you want to replace an older version of your file by using the '--backup' and '--backup-dir=/path/to/backup/folder' verbs.

Now none of us have an excuse to not have regularly backed up files (atleast the important ones).



[ Reply to This | # ]
An AppleScript for real time backups with Path Finder
Authored by: rumirocks on Apr 11, '06 03:02:00PM
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.
Why dont you implement the suggestion for replacing Finder with Path Finder found in Cocoatech's Support Forum's "Tips and Tricks" section called Sticky: Please, once and for all, how to replace Finder !

The real solution is at the bottom of this sticky thread, repeated here:

"Cmd-click on Path Finder, select "Show Package Contents".
Go to Contents, open PkgInfo.
Change "APPLPFdR" to "FNDRMACS" (ignore quotes; it's the only thing in the file).

open your path finder and go to dir "/System/Library/CoreServices/" then backup your "Finder.app" (stuffit this file and save it anywhere), now go to your path finder dir and copy "Path Finder.app" and paste it on "/System/Library/CoreServices/" dir. now just delete this "Finder.app" (remember you got a bkp ) and rename "Path Finder.app" to "Finder.app". Restart your OS and you're ready to go!

this is working like a charm here ..."


And I found it did work like a charm...although, the writer "Guest" neglected to add that you might also have to reboot from another volume to remove Finder from Core Services.

Anyway, I bought Path Finder today as a result of this hint. Thanks.

[ Reply to This | # ]
An AppleScript for real time backups with Path Finder
Authored by: markwm on Apr 11, '06 04:29:23PM

I tried out this hint, and it works.

However, as soon as you start renaming files, the backup folder will keep old versions as well as the new one. So if I have 'file.gif' saved to my source, the applescript saves it to the backup. If I then rename 'file.gif' to 'cheese.gif' the backup folder will have both 'file.gif' and 'cheese.gif'....

Any way to overcome this?



[ Reply to This | # ]
An AppleScript for real time backups with Path Finder
Authored by: e:leaf on Apr 12, '06 03:26:07AM

Why dont you implement the suggestion for replacing Finder with Path Finder found in Cocoatech's Support Forum's "Tips and Tricks" section called Sticky: Please, once and for all, how to replace Finder !

I have read that this works almost all of the time, and that there have been some problems with completely replacing the Finder. Some programs rely specifically on the Finder to do what they do. (I.e., There are some Applescript commands which are meant for the Finder and will not work with Path Finder if it has completely replaced the Finder)

I rarely have the Finder open under my current configuration. I have PF activate upon booting and automatically shut down the Finder upon launching. It generally only opens when I manually open it (to test some Applescripts mostly) or when an application which needs the Finder opens it (which is almost never).

Thanks for the tip!



[ Reply to This | # ]