10-12-2017 02:59 PM - edited 10-13-2017 06:22 AM
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.
Solved! Go to Solution.
10-13-2017 01:33 PM - edited 10-16-2017 08:52 AM
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
10-12-2017 08:55 PM
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.
10-13-2017 06:21 AM - edited 10-13-2017 06:28 AM
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
10-13-2017 01:33 PM - edited 10-16-2017 08:52 AM
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