Fork me on GitHub

Initialize Disk Image Pre and Post Hooks

This initialization script is used to dynamically generate a pre-action script and a post-action script. In essence, the dynamically generated pre-action-script will be be configured to mount the specified disk image prior to starting the backup and a post action script will be configured to un-mount the specified disk image once the backup has been completed.

This script currently only offers support for Mac OS X systems (10.4 and later).


The initialization script is located at the following path :


There is a symbolic link to this script located within the example backup configuration :


When the example backup configuration is copied (cp -a) then the copy of the example backup configuration will also contain this link. The path to this copy is what should be executed. This is because the path to the script is used to determine which backup configuration is going to have the pre and post hooks dynamically added.


Once you have configured your basic backup and generated a disk image (eg: using the hdiutil comamnd), then you are ready to run this initialization script.

In essence, the script is is run and the path to the disk image to be mounted and un-mounted is passed the first argument. An example overview of how to use this script is listed below (assuming your backup disk image is located at the following path : /Volumes/backup_drive/backup_image.sparsebundle) :

Step #1 Copy the example lbackup configuration directory:

cp -a /etc/lbackup/example_backup_config /tmp/temporary_backup_config

Keep in mind that if you want to use the backup later you should specify a destination other than /tmp. For example, you could set the destination of the copy to /etc/lbackup/my_backup

Step #2 Execute the initialization script :

/tmp/temporary_backup_config/resources/initialization-scripts/disk_images/darwin_initialize_disk_image_pre_and_post_hooks.bash /Volumes/backup_drive/backup_image.sparsebundle

The example listed above will generate two files :

Step #3 Configure the lbackup configuration file and test that the disk image is mounted and unmounted as expected.

Help / Assistance

If you are having problems with this initialization script then please post a query on the lbackup discussion mailing list.