up to John Chew's Software Archive

reflect: OS/X backup software

reflect is a Perl script that I use to synchronize important files on the OS/X machines that I look after. OS/X machines are different from regular Unix machines in that in order to support Classic MacOS resource forks, each file can optionally have a resource fork whose name is that of the main (data) fork with the string '/rsrc' appended. readdir() does not list resource forks, which breaks a lot of utilities (like tar) that would otherwise be useful for this sort of thing.

Another feature of OS/X is that if you lose a connection to an AFP-mounted volume (e.g., the laptop, whose files you like to keep mirrored to your desktop machine, but which you are prone to walking out of range with without unmounting its disk from the desktop machine), and then remount it, the Unix name of the mount point for the volume (in /Volumes) has a serial number appended to it. As far as I can tell, the easiest way to find the volume you're looking for is to look for the highest-numbered mount point.

To use the script, download the Perl code, save it in your path, set up a configuration file for each pair of folders that you want to mirror, and then list the configuration files on the command line when you invoke the script. You may want to add a cron job to do this on a regular basis.

The configuration file is described in a large comment block at the beginning of the Perl script, and is itself Perl code. Here's an example:

@mirrors = (
  {
    'from_volume' => 'iMac HD',
    'from' => '/Library/WebServer/Documents/special',
    'to'=> '/Library/WebServer/Documents/special',
    'trash'=> '/Users/jjc/backup/special-web-trash',
    'abort_on_error' => 0,
    'update_status' => 0, # don't just check size and mtime
    'verbose' => 0, 
    'quiet' => 0, 
    'copy_resource_forks' => 1,
    'stat_resource_forks' => 0, # expensive and unimplemented
  }
  );

I use this example for mirroring some of an iMac's public web space (which is accessible only on the local network) to my gateway machine's web server (which is accessible to the greater Internet). To do so, I keep the iMac's hard disk AFP-mounted on the gateway machine, and run the mirroring script periodically and on demand.

John Chew
poslfit@gmail.com
+1 416 876 7675