![]() |
![]() |
![]() |
![]() |
Appendix A Before/After Commands Specification
Before and after commands are a handy way to add functionality to your scheduled and manual backups. This section assumes the reader is familiar and comfortable with Unix shell programming. Non shell programmers may find this a bit terse.
User-Defined Commands
Using this feature, you can call scripts or programs on the server before and after the group schedule is run. For security reasons, user initiated backup and restore before and after commands must exist in or below the $BP_BINDIR directory. Also, on multi-user operating systems, the commands are run with the privileges(uid) of the user who initiated the backup. For schedules, the command lines are not modified in any way before being called by the shell. That is, the command is run as:
/bin/sh command
You may add any command-line arguments that you wish to the before/after commands. Output from the commands is directed to the schedule/task summary only if the command exits with a non-zero value. An exit value of 100 from the before command will abort the backup, and in the case of a before command for a schedule, will abort the schedule.
Since the commands are run from a daemon, the environment is minimal so do not rely on a user's specific environment. However, before calling one of the commands, certain Backup Professional environment variables are set to supply information about the schedule process.
Table 28 describes the environment set for every before or after command.
Table 29 describes variables set by the scheduler before one of the commands are called.
These environment variables are set to allow your scripts or programs to know the status of the schedule. Especially for the after command, BP_LCS_TYPES, BP_LCS_BACKUPS, and BP_LCS_STATUS is set to specify the backup numbers, types, and completion status for all backups run from the schedule. For example, the following status variables of the environment:
BP_LCS_BACKUPS="122:123:124:0:125:126"
BP_LCS_TYPES="M:V:S:V:I:V"
BP_LCS_STATUS="success:success:failed:none:failed:failed"
indicate the completion of three backups from the schedule. To better illustrate the status variables, notice the variables in a tabular format below:
BP_LCS_BACKUPS 122 123 124 0 125 126 BP_LCS_TYPES M V S V I V BP_LCS_STATUS success success failed none failed failed The values of the status variables are always listed as Backup:Verify pairs. A Verify status of None, or a Verify backup number of zero (0) indicates that the previous backup did not have the Verify After option set from the scheduler. Looking at $BP_LCS_STATUS, we see that the first backup was a Master with backup number 122 and a completion status of success. The directory $BPDIR/utils contains scripts to help you get information using these variables. Look at the scripts themselves for a description of their use.
System-Defined Command
A specific script on the client, $BPDIR/bin/taskcmds is always run before and after every task. User-defined before/after commands are executed first, followed by the execution of this script. The previous description of before/after commands including environment variables remain valid for this script except for the following.
Security is a consideration when running this script. It will not be run if the permissions of the script file for group or others allows writing. Simply stated, group and others can only have read and execute permission. Of course, the script will be run as the user-id of the user that initiated the task.
Another notable exception is the way the script is run. It is called as in the following example:
/bin/sh $BPDIR/bin/taskcmds <start|stop> <task_type> <operator> \ <catalogue>
The start/stop options indicate whether the script is called before (start) or after (stop) the task. task_type describes the type of task and is one of M, I, S, R, and V where:
· M - master
· I - incremental
· S - selective
· R - restore
· V - verify
The operator option specifies the user that initiated the task while catalogue specifies the path to the task output catalogue.
![]() |
![]() |
![]() |
![]() |