If you are backing up transaction logs of SAP/MaxDB you probably have often failed backups with status code 6.
But nothing wrong happened. Just no transactions was available for backup.
It’s a behavior of dbmcli - anything except successful backup returns exit code 1.
But parent wrapper script provided by Symantec is not able to distinguish real errors from situation where there are just no transactions to backup. (Hmm, Technote TECH129715 was deleted in meanwhile).
By Symantec we have to wait until SAP will provide dbmcli with more granular exit codes.
Seems that we cannot do anything.
Or can?
What is the standard output of successful backup? Here is one example of stdout log file from bphdb log directory:
SAP_SCHEDULED = 1
SAP_USER_INITIATED = 0
SAP_SERVER = master
SAP_POLICY = CUSTOMER1-SAP
SAP_FULL = 0
SAP_CINC = 0
OK
Returncode 0
Date 20131011
Time 00232008
Server SAPDB1
Database DB1
Kernel Version Kernel 7.9.08 Build 008-123-247-140
Pages Transferred 24
Pages Left 0
Volumes 1
Medianame BACKLog
Location \\.\pipe\BACKLog
Errortext
Label LOG_000000662
Is Consistent
First LOG Page 1990049
Last LOG Page 1990050
DB Stamp 1 Date 20131011
DB Stamp 1 Time 00230056
DB Stamp 2 Date 20131011
DB Stamp 2 Time 00230056
Page Count 1
Devices Used 1
Database ID SAPDB1:DB1_20130615_201611
Max Used Data Page
Converter Page Count
DBMCLI successful
And now something completely different:
SAP_SCHEDULED = 1
SAP_USER_INITIATED = 0
SAP_SERVER = master
SAP_POLICY = CUSTOMER1-SAP
SAP_FULL = 0
SAP_CINC = 0
ERR
-24920,ERR_BACKUPOP: backup operation was unsuccessful
The database was unable to fulfill a request (-123, No more log to save).
Execution of DBMCLI command failed - exiting
This is the example of situation when MaxDB has no transactions available since last backup. I have decided to use string “-123, No more log to save” as detector of this situation. Check whether your version of SAP/MaxDB is working the similar way.
And what is the final solution? Here is my sap_maxdb_backup.cmd
script.
@REM
@REM $Header: sap_maxdb_backup.cmd,v 1.3 2005/05/26 11:13:03 $
@REM
@echo off
@REM bcpyrght
@REM **************************************************************************
@REM * $VRTScprght: Copyright 1993 - 2012 Symantec Corporation, All Rights Reserved $
@REM **************************************************************************
REM ecpyrght
REM This environment variable are created by Netbackup (bphdb)
echo SAP_SCHEDULED = %SAP_SCHEDULED%
echo SAP_USER_INITIATED = %SAP_USER_INITIATED%
echo SAP_SERVER = %SAP_SERVER%
echo SAP_POLICY = %SAP_POLICY%
echo SAP_FULL = %SAP_FULL%
echo SAP_CINC = %SAP_CINC%
set BSI_ENV="C:\Program Files\VERITAS\NetBackup\DbExt\SAP\bsi.env"
set DBMCLI=P:\sapdb\clients\DatabaseStudio\pgm\dbmcli.exe
set DB=DB1
@set TMPFILE="C:\temp\bphdb.temp.%RANDOM%"
@set NOLOGSDETECTED_STRING="-123, No more log to save"
REM Run backup
@if "%SAP_FULL%" EQU "1" @set CMD_LINE=%DBMCLI% -d %DB% -u control,pass -uUTL control,pass backup_start BACKData
@if "%SAP_CINC%" EQU "1" @set CMD_LINE=%DBMCLI% -d %DB% -u control,pass -uUTL control,pass backup_start BACKPage
@if "%SAP_SNC_SCHED%" EQU "transactions" @set CMD_LINE=%DBMCLI% -d %DB% -u control,pass -uUTL control,pass backup_start BACKLog
%CMD_LINE% > %TMPFILE%
REM ---------------------------------------------------------------------------
REM To communicate with NetBackup's job monitor for an automatic schedule
REM a "STATUS_FILE" variable is created by NetBackup (bphdb) that contains
REM a path to a file. This file is check by Netbackup to determine if the
REM automatic schedule was successful. It is up to the script to write
REM a 0 (passed) or 1 (failure) to the status file to communicate to NetBackup
REM the status of the execution of the script. The following code echo a 0
REM to %STATUS_FILE% if succcessful and echo a 1 to %STATUS_FILE% for a
REM failure.
REM ---------------------------------------------------------------------------
if errorlevel 1 goto errormsg
echo DBMCLI successful
if "%STATUS_FILE%" == "" goto end
if exist "%STATUS_FILE%" echo 0 > "%STATUS_FILE%"
goto end
:errormsg
echo Execution of DBMCLI command failed - exiting
if "%STATUS_FILE%" == "" goto end
echo Checking if failure was not due to no logs to backup (added by Radovan Turan)
type %TMPFILE% | find %NOLOGSDETECTED_STRING% >nul
if errorlevel 0 goto nologsdetected
if exist "%STATUS_FILE%" echo 1 > "%STATUS_FILE%"
goto end
:nologsdetected
echo By dbmcli output seems that no logs are available to backup (added by Radovan Turan)
if exist "%STATUS_FILE%" echo 0 > "%STATUS_FILE%"
:end
REM Print the content of "dbmcli" to be included in bphdb log file as in standard Symantec script
echo.
echo Output of dbmcli:
echo.
type %TMPFILE%
del /Q %TMPFILE%
Change NOLOGSDETECTED_STRING string if necessary. If you will try this my modification, please, leave feedback whether it’s working fine for you or there are some issues.
Note: Line
@if "%SAP_SNC_SCHED%" EQU "transactions" @set CMD_LINE=%DBMCLI% -d %DB% -u control,pass -uUTL control,pass backup_start BACKLog
is my modification allowing me to not have separate policy for backup of transaction logs.