Pre and Post Actions

LBackup supports running scripts before and after a backup. This allows LBackup users great deal of flexibility.

Pre and post scripts allow for a variety of things to happen on the system before or after a backup. Below is a list of common uses for pre and post scripts.

The examples above are just scratching the surface of what is possible with pre and post actions.

How Pre and Post Actions Work

Firstly, if you would like to you may specify your own pre or post action script in the configuration files.

Leaving the configuration options blank will result in the default pre and post actions runnning. These default pre and post actions will search for any executable scripts with file names that begin with the action prefix “BACKUP”. These pre and post scripts must reside in the following directories :

Using the default LBackup pre and post scripts provides an easy way specify multiple post and pre action scripts for each backup configuration. It is also possible to specify to order these actions are executed.

The default pre and post action scripts are located at the following paths.

The scripts which are executed by the backup system can be any kind which is supported by the operating system.

There are a range of environment variables which are made available to the pre and post action scripts by LBackup. This allows the scripts to be written in a way which often allows them to be portable between different backup configurations.

Return Codes

Return codes are exported as shell variables to the pre and post action scripts. The purpose of return values, is to allow the LBackup system to determine whether to continue with the backup and or the other pre and post scripts. The script_return_codes.conf (full path listed below) specifies the script return codes.

When the pre or post script passes control back to LBackup, the return code is used to determine whether the backup should continue or exit. In addition the return codes are also used for backup execution logging.

Example Scripts

Example scripts are provided within the example-scripts directory located within the resources directory of the example configuration folder. If you would like to have your script added to the LBackup distribution please visit the contributions page.