Running pre and post commands for restore jobs

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

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

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

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

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

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

To set up commands to run before or after a restore job

  1. On the Properties pane, under Settings, click Pre/Post Commands.

  2. Select the following options as needed:

    Pre-command

    Specify a command to be run on the specified server before the 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 restore job runs. 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 the command completed successfully. A non-zero exit code is interpreted by Backup Exec as 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 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 not run if the pre-command fails, then select Allow pre- and post-job commands to be successful only if completed with a return code of zero. If a non-zero exit 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 fail 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 exit 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 is not run.

    If you also select Run job only if pre-job 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 if 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.

    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 restored to

    Select this option to run the pre- and post-commands one time on each server to which data is restored during this job.

    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

Restoring data by setting job properties

Setting default pre/post commands