Here is a short video of how to automatically issue specified commands before or after running a backup job.
You can define commands to be executed before the backup job runs and after the backup job runs. They are often used to perform custom OS-specific or application-specific tasks, such as to stop/start a database. Commands are defined on the Properties > Advanced > Execution page of a backup job.
The Pre-execution tab on jobs controls the command to be executed before the job is run, either on multiple hosts or on the master server. In addition there are options to control whether to stop the job stop or whether to continue the job based on the outcome of the command.
|Command path||Specifies a full path or relative path to a shell command, including command parameters. For instance cmd.exe /c explorer.exe or c:\windows\explorer.exe. This field also supports a macro syntax for many different uses. See the Yosemite Server Backup Technical Reference Guide for more information.|
|Run command on all hosts selected in job, as well as the Domain Server||When checked, processes the command on all machines selected in a job. When unchecked, the command only runs on the master server.|
|Number of minutes to wait for command completion||This value specifies in minutes how long the application should wait for the command to complete. By default, this option is set to Forever, meaning the application waits for as long as possible for the command to complete. If set to something other, then the application will terminate the command forcefully if it does not return in time.|
|Stop job if command fails to be executed||When checked, causes the job to be stopped if the pre-command fails to execute, as if the command does not exist or the operating system cannot property determine how to execute the command.|
|Stop job if command returns error code||When checked, causes the job to be stopped if the pre-command executes but returns a non-zero code. When checked, enables the additional options beneath it.|
|Do not stop job if the following error code range is returned||When checked, a range of error codes must be specified in the Start and End text boxes. If the error code returned is zero or is within the specified range, the job continues. However, if the return code is non-zero and outside of the specified range, the job is stopped.|
The post execution job property controls what shell commands should be executed after the job completes with no error or with error.
|Command to execute if job completes with no error||This command executes if the job completes with no final error. A job can complete with no error, even if all hosts are offline. It does not mean that anything was backed up, only that the job was not cancelled or there was not some other major problem executing the job.|
|Command to execute if job completes with error||This command execute if the job completes with an error, such as no specified devices, or operator cancelled. It does not mean that any of the objects selected by the job failed to be backed up, restored, or verified.|
|Command path ||Specifies a full path or relative path to a shell command, including command parameters. For instance, cmd.exe /c explorer.exe or c:\windows\explorer.exe. A macro syntax is also supported in this field, for many different uses. See the Yosemite Server Backup Technical Reference Guide for more information.|
|Run command on all hosts selected in job, as well as the Domain Server||When checked, processes the command on all machines selected in job. When unchecked, only runs the command on the Domain Server.|
|Number of minutes to wait for command completion||This value in minutes specifies how long the application should wait for the command to return. By default, it is set to Forever, meaning the application will wait for as long as possible for the command to complete. If set to something other than Forever, the application will terminate the command forcefully if it does not return in time.|
Command Execution Logs
The pre/post commands add detailed logs to the jobs that execute them. A new execution section is added to the job log, where all commands executed by the job are logged.
|Command type||Indicates whether the command was a pre-job/post-job/fail job or a pre-object/post-object/fail object command.|
|Command path||The fully macro expanded command path sent to the operating system for execution.|
|Host attempted on||The host name on which the command was attempted.|
|Time executed||The start time when the command was attempted.|
|Time completed||The end time when the command either timed out and was killed, or when it completed on its own accord.|
|Execution result||The result of the execution, either the execution failed, or the execution succeeded. If the execution succeeded, then the return code of the command will be logged here. If no return code is logged, then success is logged here.|