cancel
Showing results for 
Search instead for 
Did you mean: 

MAXDB Recovery Log Shipping

jk_kar2
Explorer
0 Kudos

Hi All,

We have Build DR Standby System which we have restored from Prod System into a Standby System.

We have used the Log Shipping Script which is available in the below wiki Link

HowTo - Standby System (Recovery from Log Backup) - MaxDB - SCN Wiki

Our SAP Landscape Environment is Windows OS 2008 and MAXDB 7.6

Well, This Script  consist in 3 files: Standby.Bat, Recovery_Builder, Recovery_Apply. We have implemented these scripts in STANDBY SERVER,


We've tried to adapt the code for our system landscape but when we execute the script we're running into an error:


And we are facing issue in the 2nd Script RECOVERY_BUILDER, As per the script it will Set DB to Admin mode and then builds the import list and exports to script file.


I have tried this script but no success i.e i cannot generate the Script file, The Script is Working till : EXIT LOOP


Please find our adapted Script with changed LOG Path, DBMCLI, Passwords


RECOVERY BUILDER :


rem %%a = Logfile Name

rem %%b = log file number

rem %%j = Page number

Set LiveDB=SAPDMSPRD.domain.com

C:\sapdb\programs\pgm\dbmcli.exe -n localhost -d SDB -u SUPERDBA,XXXXX db_admin

for /f "usebackq tokens=1,2,3,4 delims= " %%a in (`"C:\sapdb\programs\pgm\dbmcli.exe -n localhost -d SDB -u SUPERDBA,XXXXXXX db_restartinfo |findstr /c:"Used LOG Page""`) do (set current_page=%%d)

for /f "usebackq tokens=1,2 delims=." %%a in (`"dir Z:\DR_DataBackup\Log_Bkp\. /b /o:e"`) do (

     for /f "usebackq tokens=1,2,3,4 delims= " %%g in (`"C:\sapdb\programs\pgm\dbmcli.exe -n SAPDMSPRD.domain.com -d SDB -u SUPERDBA,XXXXXXX medium_label SDB_log_bkp %%b |findstr /c:"Last LOG Page""`) do (

          call :find_backup_page  %%j %%a %%b

     )

)

:exit_loop

for /f "usebackq tokens=1,2 delims=." %%a in (`"dir Z:\DR_DataBackup\Log_Bkp\. /b /o:e"`) do

(

if %%b GTR %first_file% (

echo recover_replace SDB_log_bkp "Z:\DR_DataBackup\Log_Bkp" %%b >> c:\temp\import_script.txt))

goto end

:find_backup_page

          set /i backup_page="%1"

          if /i %current_page% EQU "%1" (

               echo db_connect > c:\temp\import_script.txt

               echo db_admin > c:\temp\import_script.txt

               echo recover_start SDB_log_bkp LOG %3  >> c:\temp\import_script.txt

               set first_file=%3

               pause

          goto exit_loop

          )

:end

The Live DB variable is PROD Server Hostname FQDN

LOG Backup Path = Z:\DR_DataBackup\Log_Bkp

Backup_Medium_Label = SDB_log_bkp

I have run the script manually with 3 log files generated manually, The Script is giving me values of Current USED log page and LAST LOG PAGE,

After this EXIT LOOP the script comes out of loop and doesn't generating the script file.

Could you provide me what are wrong in my adapted scripts and help me with them??


Thanks,

Karthick V

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Hello,

I am also looking for the working script of Recovery_Builder.bat as per https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=72123826, anyone has managed to do it?

Thanks in advance.

0 Kudos

Hello, just put more outputs in you script, to see what is not working. For example:

:find_backup_page

  echo executing find_backup_page

  set /i backup_page="%1"

  echo the backup page %backup_page%

  echo the current page %current_page%

...

and so on.

Good Luck

jk_kar2
Explorer
0 Kudos

Hi Alex,

After adding the lines in the script, The script is abruptly closing  and coming out of command prompt.

Please find the screenshot attached here - in for references.

Thanks,

Karthick V

jk_kar2
Explorer
0 Kudos

Hi ALex,

After Inserting more lines in the script, Getting the Current Page and Backup Page values, Pls find the screenshot attached here in.

But the script is not generating the notepad file (import_script.txt). The Command prompt closing abruptly. Need your assistance on the script oh this.

attached the screenshot for reference.

Thanks,

Karthick V

0 Kudos

you can see the erro message:

set /i backup_page=5601841

The syntax of the command is incorrect .

you should use 'set backup_page="%1" ', without '/i'

jk_kar2
Explorer
0 Kudos

Hi Alex,

I have taken complete data backup from primary and restored in the standby server with initialization, Then i have taken the Log Backup manually from primary and i moved it manually to the standby server, As my log backup number is 135 as mentioned in the screenshot.

So currently i have one log backup file 135 in the path E:\DR_Database_bkp\Log_Bkp\au*.*

As suggested, I removed the /i and Tried already in the cmd prompt there is no syntax error this time but you can see the backup page = 5601841

and current_page = 5600726.

In the Script it is checking the condition  if %current_page% EQU %1

But the backup page and current page values are different as mentioned in screenshot

Hence the script coming out of loop and exiting :end as mentioned in the script.

Thanks,

Karthick V

0 Kudos

ok, your skript is workin correct. only backups which start page could aligned with the current page on the database can be used. the backup file with number 135 is not suitable because there is a gap between current page on the database and start page on the log backup.

jk_kar2
Explorer
0 Kudos

Hi Alex,

The Script is working correct, The Backup Page and Current Page are equal and if it is equal the script has to generate the import_script file, The import_script file is generated and it has incomplete details inside. Pls find the attached screenshot here in.

The expected output in the script file is different from what i am getting, The If Condition in the Below Script is not working for me

if %current_page% EQU %1 (

echo db_connect >> import_script.txt

echo db_admin >> import_script.txt

echo recover_start Auto_log_Backup LOG %3 >> import_script.txt

set first_file=%3

if %current_page% GTR %1 goto exit_loop

Thanks,

Karthick V

Karthick

0 Kudos

Hello Karthick V,

in your script you can advise to set numerical value only for the current_page variable (set /A current_page=%%d):

for /f "usebackq tokens=1,2 ... in (`"c:\sapdb\programs\...\dbmcli.exe -n ... db_restartinfo | findstr /c: "Used LOG Page""`) do (set /A current_page=%%d)

regards, Alexander

jk_kar2
Explorer
0 Kudos

Hi ALex,

As Suggested, Set an numerical Value

set /A current_page=%%d

for /f "usebackq tokens=1,2 ... in (`"c:\sapdb\programs\...\dbmcli.exe -n ... db_restartinfo | findstr /c: "Used LOG Page""`) do (set /A current_page=%%d)


Getting command line error, It didnt help


The Issue is facing currently is the backup and current page are same but still the script not generating the

Import_Script file as below


     echo db_connect >> N:\Scripts\import_script.txt

      echo db_admin >> N:\Scripts\import_script.txt

      echo recover_start Auto_log_Backup LOG %3 >> N:\Scripts\import_script.txt


Instead i am getting the below file


Thanks,

Karthick V

0 Kudos

I cannot see that you did the change. Could you attach the current recovery builder script?

jk_kar2
Explorer
0 Kudos

Hi Alex,

Pls find the attached Recovery Builder script Below :

rem %%a = Logfile Name

rem %%b = log file number

rem %%j = Page number

Set LiveDB=DRhostname.domain.com.om

C:\sapdb\programs\pgm\dbmcli.exe -n localhost -d SDB -u SUPERDBA,XXXX db_admin

for /f "usebackq tokens=1,2,3,4 delims= " %%a in (`"C:\sapdb\programs\pgm\dbmcli.exe -n localhost -d SDB -u SUPERDBA,XXXXX db_restartinfo |findstr /c:"Used LOG Page""`) do (set current_page="%%d")

pause

for /f "usebackq tokens=1,2 delims=." %%a in (`"dir Z:\DR_DataBackup\Log_Bkp\au*.* /b /o:e"`) do (

for /f "usebackq tokens=1,2,3,4 delims= " %%g in (`"C:\sapdb\programs\pgm\dbmcli.exe -n localhost -d SDB -u SUPERDBA,XXXXX medium_label Auto_log_Backup %%b |findstr /c:"Last LOG Page""`) do (

call :find_backup_page %%j %%a %%b)

)

:exit_loop

for /f "usebackq tokens=1,2 delims=." %%a in (`"dir Z:\DR_DataBackup\Log_Bkp\au*.* /b /o:e"`) do (

if %%b GTR %first_file% ( echo recover_replace Auto_log_Backup E:\DR_Database_bkp\Log_Bkp\Autolog %%b >> N:\Scripts\import_script.txt

)

)

goto end

:find_backup_page

echo executing find_backup_page

set backup_page="%1"

echo the backup page %backup_page%

echo the current page %current_page%

pause

if %current_page% EQU "%1" (

      echo db_admin >> N:\Scripts\import_script.txt

      echo db_connect >> N:\Scripts\import_script.txt

      echo recover_start Auto_log_Backup LOG %3 >> N:\Scripts\import_script.txt

      set first_file=%3

      if %current_page% GTR %1 goto exit_loop

      )

:end

Thanks,

Karthick V

0 Kudos

Hell,

I'm missing the /A option there.

The script below contains this option. Please check

rem %%a = Logfile Name rem %%b = log file number rem %%j = Page number Set LiveDB=DRhostname.domain.com.om C:\sapdb\programs\pgm\dbmcli.exe -n localhost -d SDB -u SUPERDBA,XXXX db_admin for /f "usebackq tokens=1,2,3,4 delims= " %%a in (`"C:\sapdb\programs\pgm\dbmcli.exe -n localhost -d SDB -u SUPERDBA,XXXXX db_restartinfo |findstr /c:"Used LOG Page""`) do (set /A current_page="%%d") pause for /f "usebackq tokens=1,2 delims=." %%a in (`"dir Z:\DR_DataBackup\Log_Bkp\au*.* /b /o:e"`) do ( for /f "usebackq tokens=1,2,3,4 delims= " %%g in (`"C:\sapdb\programs\pgm\dbmcli.exe -n localhost -d SDB -u SUPERDBA,XXXXX medium_label Auto_log_Backup %%b |findstr /c:"Last LOG Page""`) do ( call :find_backup_page %%j %%a %%b) ) :exit_loop for /f "usebackq tokens=1,2 delims=." %%a in (`"dir Z:\DR_DataBackup\Log_Bkp\au*.* /b /o:e"`) do ( if %%b GTR %first_file% ( echo recover_replace Auto_log_Backup E:\DR_Database_bkp\Log_Bkp\Autolog %%b >> N:\Scripts\import_script.txt ) ) goto end :find_backup_page echo executing find_backup_page set backup_page="%1" echo the backup page %backup_page% echo the current page %current_page% pause if %current_page% EQU "%1" (       echo db_admin >> N:\Scripts\import_script.txt       echo db_connect >> N:\Scripts\import_script.txt       echo recover_start Auto_log_Backup LOG %3 >> N:\Scripts\import_script.txt       set first_file=%3       if %current_page% GTR %1 goto exit_loop       ) :end

jk_kar2
Explorer
0 Kudos

HI Alex,

As Suggested changed the script as do (set /A current_page="%%d")

I have got the output in import_script file as below

The Issue here is even if the Backup and Current page is same the If condition in not working as it not writing the echo command in the output file, Please find the below screenshot for if condition highlighted in Yellow color

Thanks,

Karthick V

0 Kudos

Hello,

why don't you play around? the scripts on the SCN MaxDB page are only suggestions. They are done not by MaxDB developers, and we cannot garantee that they are working in every environemnt..

My suggestion: after label:

:find_backup_page

set /A backup_page = "%1"

Good Luck

p.s. Good Luck is not part of script ...