Shell push Backup Introduction

Filemaker schedules are used to create periodic backups into the deafult backup directory path /Library/FileMaker Server/Data/Backups. The requirement is to then replicate those backups to a readily accessible directory of the server hard drive, where the backup can be removed to external media.

Several approacheds to this can and have been used, including cron jobs which allow scheduled execution of shell scripts. Launchd is now the Apple preferred method of scheduling such tasks. The method is fairly simple; a 2 line shell script file is created in a text editor and saved, then a plist file is created using Lingon, which is aplis editor. A handfull of no cost small apps make the process strightforward.

launchd daemon

The launchd daemon offers a single, standardized, interface to any and all programs started automatically by the system. Furthermore, the configuration files that determine when to run a given program can also specify resource limits and environment variables, which simplifies setup and security for many programs. The same configuration file format is used whether a job is launched once at system startup or user login, on demand over the network, or at intervals

Launchd is just an XML docume't (called a 'plist' because it sets preferences) that will run actions that were formerly the domain of cron and other system functions. 'Plist' just stands for 'Property List.' A text editor such as Smultron or TextWrangler is used to create the shell script. TextEdit can be used but there can be issues with hidden line endings; Smultron and Text Wrangler avoid this by allowing one to specify UNIX line breaks and UTF-8 character encoding.

A Launch Daemon isn't just for use at launch time; it can be used ANYTIME. It's just LOADED at launch time.

Software to make all this easier (all free)

  • Smultron or TextWrangler text editors
  • BatChmod permissions editor
  • Lingon launchd configuration editor

Launchd in preference to cron

The cron daemon has been the most common tool for executing a job at a particular time. Although all versions of Mac OS X support cron jobs, beginning in v10.4, the functionality of cron is largely superseded by launchd, and all periodic jobs built into Mac OS X are launchd jobs.

A cron job is not guaranteed to run. If the system is turned off or asleep at the designated time, the job does not execute until the designated time occurs again.

Method overview

The overall process is fairly simple, and both a testing on a local mac protocol, and a server version are detailed in the following discussion. The basic process is:

  • create a 2 line shell script in a text editor to specify the backup from where to where
  • specify the appropriate shell script file permissions using BatChmod
  • Create the launchd file using Lingon, that executes the shell scrip, and specifies when and how often to execute it.
  • log out, log in