cancel
Showing results for 
Search instead for 
Did you mean: 

BE2015 Pre/Post Command Return/exit code not failing job when returning non zero

ksaint-vil
Level 3

Hello i am having an issue with how Backup exec fails a job, when a pre command returns a non zero.

The issue is when my Bat script returns a non zero.Backup Exec continues the backup, if a "0" was returned, but in the coded it would explictly have exit /b 1. here is an example:

"Powershell.exe -File  c:\Scripts\Prebackup.ps1
IF %ERRORLEVEL% NEQ 0 GOTO Error

@REM... Succussful
exit /b 0

:Error
@REMprocess error. Unsuccessful
exit /b 1"

On windows CMD, powershell, and BEMCLI all displays all correct error codes when code exits with non zero but once again when it is run on pre/post command in a backup job. BE doesnt read the exit code.

Any help will be appreciative.

1 ACCEPTED SOLUTION

Accepted Solutions

ksaint-vil
Level 3

I figured out the issue.

When running the Batch file, it seems like BE processes the exit /b 0 command even if the conditional statement states not to do so.

A work around was to have my script call the backup job manually within the script itself. and if the script fails it wont call the backup exec job

 

 

 

 

View solution in original post

3 REPLIES 3

pkh
Moderator
Moderator
   VIP    Certified

This is the correct behaviour.  BE does not interpret the return codes of pre-/post-commands.  It only act on failures.

To you, a return code of 1 means a failure, but to another person, it could be just a warning and only a return code of 8 and above is a failure.  How is BE going to interpret return codes?

If you don't want BE to continue, then fail the batch file using the /B parameter of the Exit command.

i had a mis-type when transfering code to forum. it should be :

:Error
@REMprocess error. Unsuccessful
exit /b 1"

Just like the line above.

however, even when having "/B" parameter, BE still processes the the job as an exit error code of 0 instead of a non zero.

I have all nesscary check boxes selected in the job to read return code, and to not continue the backup if precommand fails.

Is there something else i am missing

ksaint-vil
Level 3

I figured out the issue.

When running the Batch file, it seems like BE processes the exit /b 0 command even if the conditional statement states not to do so.

A work around was to have my script call the backup job manually within the script itself. and if the script fails it wont call the backup exec job