Forum Discussion

taolv's avatar
taolv
Level 3
2 years ago

About DB2 alternate restore

Dear friends,
I want to restore DB2 databases to a different client/instance, from a schedualed daily backup.
and I have several questions because it's my first time to do the DB2 restore.
Could you please help.

[enviroment]
Redhat enterprise server release 6.10, NBU v7.7.3, DB2 Enterprise Server Edition 10.5

[Server Policy]
A daily DB2 type policy with 2 scheduals(application backup &Automatic Full backup) and one backup script is configured and in use.

[db2.conf]
In this config file, there are object identifier statements for backing up databases only, no object identifier for backing up the archive logs,or for functions.

[backup scripts]
In this script, “db2 backup db xxxx online load /usr/openv/netbackup/bin/lib include logs” is coded, which is schedualed to excute daily.

[Documentation]
I have read the topic "About an alternate restore" in Chapter 4. Performing backups and restores of DB2 of the "NetBackup? for DB2 Administrator's Guide release 7.7"

[question]
1. I want to restore DBs to a specific date(ex:2022/9/1), and I can't find the info where and how to specify this date option during the restore configration in above guide.
2. Were archieve logs and active logs backed up daily in my backup configration, if not, which logs are required for this specific date restore task, or none of them is required?

  • This is the backup script in use; I paste the contents here, as I could't attache the file, don't why.

    excuse me for any inconvenience may cause.

     

     

    #!/bin/sh

    #bcpyrght
    #***************************************************************************
    #* $VRTScprght: Copyright 1993 - 2012 Symantec Corporation, All Rights Reserved $ *
    #***************************************************************************
    #ecpyrght

    #
    # These environment variables are initialized by Netbackup (bphdb)
    #

    echo "DB2_CLIENT = $DB2_CLIENT"
    echo "DB2_SERVER = $DB2_SERVER"
    echo "DB2_POLICY = $DB2_POLICY"
    echo "DB2_SCHED = $DB2_SCHED"
    echo "DB2_FULL = $DB2_FULL" # Is 1 if Full backup scheduled
    echo "DB2_CINC = $DB2_CINC" # Is 1 if Cumulative incremental scheduled
    echo "DB2_INCR = $DB2_INCR" # Is 1 if Differential incremental scheduled

    #
    # Change MY_LIB to the correct NetBackup library name for your host:
    # Solaris or Linux 32-bit = nbdb2.so
    # Solaris 64-bit = nbdb2.so64
    # HPUX (ia64) = nbdb2.so
    # AIX or HPUX = nbdb2.sl
    # AIX or HPUX = nbdb2.sl64
    #

    MY_LIB=/usr/openv/netbackup/bin/nbdb2.so64

    #
    # Change MY_DB2 to the correct DB2 instance name for your database.
    #

    MY_DB2=XXXXXX_DB

    #
    # Use the NetBackup schedule type to set DB2 full or incremental options.
    #

    if [ "$DB2_FULL" = "1" ] ; then
    MY_SCHED=""
    elif [ "$DB2_CINC" = "1" ] ; then
    MY_SCHED="INCREMENTAL"
    elif [ "$DB2_INCR" = "1" ] ; then
    MY_SCHED="INCREMENTAL DELTA"
    else
    MY_SCHED=""
    fi

    #
    # Initialize the backup command line.
    # Customize the number of sessions and buffer options for your environment.
    #

    #CMD_LINE="db2 BACKUP DATABASE $MY_DB2 $MY_SCHED LOAD $MY_LIB OPEN 4 SESSIONS BUFFER 1024"
    CMD_LINE="db2 BACKUP DATABASE $MY_DB2 online $MY_SCHED LOAD $MY_LIB OPEN 4 SESSIONS BUFFER 1024 include logs"

    #
    # Change MY_USER to the proper DB2 user for performing backups
    #

    MY_USER=db2inst1

    echo "Executing: $CMD_LINE"
    su - $MY_USER -c "$CMD_LINE"

    RETURN_STATUS=$?

    # Return 0 for success, non-zero for errors

    exit $RETURN_STATUS

     

    • Michal_Mikulik1's avatar
      Michal_Mikulik1
      Moderator

      Hello,

      very generally you will use these commands:

      restore database <DB> into <ALTDB> logtarget <LOGDIR> redirect

      set storgroup paths to <ALTPATH> 

      restore database continue

      rollforward db  <ALTDB> to <point-in-time> using local time and stop

      For a more detail, check a DB2 documentation, I also recommend you to cooperate with a DB2 admin if you have any.

      The procedure is for a alternate db on the same server. Scenario for a different server would be more complicated and I dont have an experience with it.

      Regards

      Michal

       

       

       

       

      • taolv's avatar
        taolv
        Level 3

        Good day Michal,

        Thanks for your updating. and I've one more question if appropriate.

        For this command, "rollforward db  <ALTDB> to <point-in-time> using local time and stop".

        How can I technically identify the earliest date that I can use with "rollforward " command. 

        The task I was given is to restore the DB to 29th June 2022. What I want is to make sure ahead that the backup is there.

  • Can someone assist my last question here,please?