Skip to Content
author's profile photo Former Member
Former Member

Recovery LOG Script

Hi we have copied our PRD system into a new box.

The new system is not a standby system of the PRD system, just a copy.

We have build a script that sends logbackups to tape and to this new system for recovery.

Is there a way to recover the log on the copied system with a script without user interaction?

I have tried this but no sucess

dbmcli -d PRD -u superdba,******* recover_start Autologbackup LOG

-24991,ERR_NODBSESSION: no database session available

Any help?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 14, 2008 at 11:02 PM

    I have read before posting the link you mention but i cannot see how to automate it.

    The link explain how to do it inside the DBMCLI with manual steps, what I need is to run a script in unix and restore the log without user interaction in the whole process, not even in DBMCLI.

    Thank you.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Lars Breddemann

      Well here it is, it consist in 2 files: restore.txt and restore_script. It only restores 1 log backup on each run.

      So you probably add it to a cron. It was made in Solaris 5.10.

      the logbackups should have 666 rights on it so prdadm can delete them after restore.

      Restore.txt has the commands that the dbmcli should execute once inside the dbmcli.

      Contents of restore.txt

      db_admin

      db_connect

      recover_start Autologbackup LOG 1

      recover_replace Autologbackup /sapdb/PRD/logbackups/logbackupPRD 2

      recover_cancel

      The restore_script has the logic for changing restore.txt before executing it

      #!/bin/bash

      IND=`ls /sapdb/PRD/logbackups/logbackupPRD* | cut -d. -f2 | sort -r | tail +2 | sort -r`

      for i in $IND; do

      ANT=`echo $i - 1 | bc`

      POS=`echo $i + 1 | bc`

      sed '/recover_start/s/'$ANT'/'$i'/g' /home/prdadm/restore.txt | sed '/recover_replace/s/'$i'/'$POS'/g' > /tmp/restore.$i.tmp

      DIF=`diff /home/prdadm/restore.txt /tmp/restore.$i.tmp | wc -l`

      if [ $DIF -eq 0 ]; then

      echo "Error"

      exit 1

      else

      cp /tmp/restore.$i.tmp /home/prdadm/restore.txt

      dbmcli -U c -i /home/prdadm/restore.txt

      if [ $? -eq 0 ]; then

      rm /sapdb/PRD/logbackups/logbackupPRD.$i

      rm /tmp/restore.$i.tmp

      else

      echo "Error"

      exit 1

      fi

      fi

      done

      exit 0

      Edited by: Daniel Rajmanovich on Oct 17, 2008 5:23 PM

  • author's profile photo Former Member
    Former Member
    Posted on Dec 06, 2008 at 12:04 AM

    Hi all

    And if anyone need a small script for windows environment:

    (obviously, you will need to change the program paths, users and password - which you can also store in a file)

    D:\sapdb\programs\pgm\dbmcli.exe -n localhost -d LDP -u SUPERDBA,xxxx db_admin

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

    set current_page="%current_page:* =%"

    pause

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

    for /f "usebackq tokens=1,2,3,4 delims= " %%g in (`"D:\sapdb\programs\pgm\dbmcli.exe -n localhost -d LDP -u SUPERDBA,xxxx medium_labeloffline lclogbackup %%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 I:\LClogbackup\lc. /b /o:e"`) do (

    if /i %%b gtr %first_file% (echo recover_replace LClogbackup "I:\LClogbackup\LClogbackup" %%b >> c:\temp\import_script.txt))

    D:\sapdb\programs\pgm\dbmcli.exe -n localhost -d LDP -u SUPERDBA,xxxx -i "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 recover_start LClogbackup LOG %3 >> c:\temp\import_script.txt

    set first_file=%3

    pause

    goto exit_loop

    )

    :end

    hope it will help anyone who need to do automatic log shipping for maxdb.

    It is not the smartest script but it does the trick.

    Eitan

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      When I tried to use script suggested by Daniel Rajmanovich Oct 17, 2008 5:29 PM in this thread, it is taking restore from log 001 but in my case I have already restored 700 logs now I want automatic restore through script should be started from 701 instead of 001.

      Hope you got my point.

      Awaiting for the response.

      Regards,

      Rohit

  • Posted on Oct 14, 2008 at 09:22 PM

    > We have build a script that sends logbackups to tape and to this new system for recovery.

    Ok, so the logshipping is done.

    > Is there a way to recover the log on the copied system with a script without user interaction?

    Sure - and you know what? They even documented it...

    [Setting Up and Updating Standby Instances|http://maxdb.sap.com/doc/7_6/43/6799434c355f6ce10000000a1553f6/content.htm]

    > I have tried this but no sucess

    > dbmcli -d PRD -u superdba,******* recover_start Autologbackup LOG

    > -24991,ERR_NODBSESSION: no database session available

    Yeah, well - you did it wrong.

    > Any help?

    s.a.

    regards,

    Lars

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.