Pre/post commands for backup or restore jobs

To set commands to run before or after a job, on the Properties pane of the Backup Job Properties dialog box, the Restore Job Properties dialog box, or the New Backup Job Template dialog box, under Settings, click Pre/Post Commands.

You can run commands before or after a backup or restore job, and set the following conditions for these commands:

If it is critical that the job does not run if the pre-command fails, then configure Backup Exec to check the return codes of the pre- and post-commands to determine if the pre-command failed or completed successfully.

For example, if a pre-command that shuts down a database before a backup is run fails, the database could be corrupted when the backup is run. In this situation, it is critical that the backup job does not run if the pre-command fails.

Additionally, if Backup Exec is configured to check the return codes of the pre- and post-commands, and the post-command returns a non-zero code, the job log reports that the post-command failed. If you also selected to run the job only if the pre-command is successful, and both the pre-command and the job ran successfully, Backup Exec will mark the job as failed if the post-command fails.

For example, if the pre-command runs successfully and shuts down the database and the backup job also runs successfully, but the post-command cannot restart the database, Backup Exec marks the job and the post-command as failed.

If you select the option On each server backed up, the pre- and post-commands are run and completed for each server before processing begins on the next selected server.

This dialog box includes the following options:

Table: Pre- and post-command options

Item

Description

Pre-command

Specify a command to be run on the specified server before the backup or restore job is run. Use local paths, and make sure the paths exist on each server and are correct.

Commands that require user interaction, such as prompts, are not supported.

Post-command

Specify a command to be run on the specified server after the backup or restore job has run. Use local paths, and make sure the paths exist on each server and are correct.

Commands that require user interaction, such as prompts, are not supported.

Allow pre- and post-commands to be successful only if completed with a return code of zero

Select this option to allow Backup Exec to check the return codes of the pre- and post-commands to determine if they completed successfully.

An exit code of zero returned to the operating system by the pre- or post-command is interpreted by Backup Exec to mean that the command completed successfully. A non-zero exit code is interpreted by Backup Exec to mean the command ended with an error.

After checking the return codes, Backup Exec continues processing according to selections you made for running the pre- and post-commands.

If this option is not selected, the success of the pre- and post-commands is not determined based on the return code.

Run job only if pre-command is successful

Select this option to run the backup or restore job only if the pre-command is successful. If the pre-command fails, the job does not run, and is marked as failed.

If it is critical that the job does not run if the pre-command fails, then select Allow pre- and post-commands to be successful only if completed with a return code of zero. If a non-zero code is returned, it is interpreted by Backup Exec to mean that the pre-command did not run successfully. The job is not run and the job status is marked as Failed.

Run post-command only if pre-command is successful

Select this option to run the post-command only if the pre-command is successful.

If it is critical that the post-command does not run if the pre-command fails, then select Allow pre- and post-commands to be successful only if completed with a return code of zero. If a non-zero code is returned for the pre-command, it is interpreted by Backup Exec to mean that the pre-command did not run successfully. The post-command does not run.

If you also select Run job only if pre-command is successful, and both the pre-command and the job are successful, but the post-command returns a non-zero code, the job log reports both the job and the post-command as failed.

Run post-command even if job fails

Select this option if it is critical to run the post-command regardless of whether the job is successful or not.

If you also select Allow pre- and post-commands to be successful only if completed with a return code of zero and the post-command returns a non-zero code, the job log reports the post-command as failed.

Run post-command after job verification completes

If you selected the Verify after backup completes option on the General backup properties dialog box, select this option to run the post-command after the verification completes.

Cancel command if not completed within x minutes

Select the number of minutes Backup Exec should wait before canceling a pre- or post-command that did not complete. The default time-out is 30 minutes.

On this media server

Select this option to run the pre- and post-commands on this media server only.

On each server backed up

Select this option to run the pre- and post-commands one time on each server backed up.

The pre- and post-command selections apply to each server independently. If you select this option, the pre- and post-commands are run and completed for each server before processing begins on the next selected server.

More Information

Creating a backup job by setting job properties

Setting default backup options

Setting default pre/post commands