Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2012
    Posts
    2

    Arrow Unanswered: Recent Backup Check script

    I am trying to write a script that checks the recent backups. i figured out something and write a draft..could anyone help me out get it fixed fully.

    #!/bin/ksh
    . ~$HOME/sqllib/db2profile

    ################################################## ##################
    # ASSIGN DEFAULTS. DEFAULTS MAY BE OVERWRITTEN BASED ON INPUT ARGS
    ################################################## ##################

    DBA=/dba
    INST=
    CONN=FALSE
    OUTF=/tmp/dbbkpcheck.out
    typeset -i TScurrent=`date +%Y%m%d%H%M%S`
    export DBA

    ################################################## ###################
    # READ IN STANDARD DBA FUNCTIONS
    ################################################## ###################

    . $DBA/bin/standard_functions

    ################################################## ###################
    # VERIFY THAT THE INSTANCE EXISTS
    ################################################## ###################

    get_instance_list A
    if [ -n "$INST" ]; then

    VALID=FALSE

    for ITEM in $DB2INSTLIST
    do
    if [ $INST = $ITEM ]; then
    VALID=TRUE
    break
    fi
    done

    if [ $VALID = "FALSE" ]; then
    echo "\n$INST DOES NOT EXIST ON SERVER\n"
    echo "Valid instances are:\n"
    echo $DB2INSTLIST
    echo " "
    exit 2;
    fi
    else
    INST=$DB2INSTLIST
    fi


    ################################################## ###############
    # LIST DATABASES ON INSTANCES
    ################################################## ###############

    for INSTANCE in $INST
    do
    cinst $INSTANCE

    DB_LIST=`db2 list db directory | grep -ip indirect | awk '/Database name/ {printf("%s\n",$4)}' | sort`

    echo $DB_LIST

    for DATAB in $DB_LIST
    do
    db2 connect to $DATAB
    typeset -i TSLastBackup=`db2 -x " SELECT START_TIME FROM SYSIBMADM.DB_HISTORY where OPERATION='B' order by START_TIME desc fetch first row only"`
    echo $TSLastBackup
    if [[ $CKTimestamp -le 1000000 ]]
    then
    echo " Yesterday Backup successful"
    fi
    done
    done
    exit


    thanks in advance..

  2. #2
    Join Date
    Mar 2012
    Posts
    10
    Are you getting a specific error ? What is the script not doing ?

  3. #3
    Join Date
    Mar 2012
    Posts
    2
    I want to check the recent backups of all the instances in the server.
    and it should say like:

    if the backup is taken 2days back..it should say is 2 days and check for last 7 days.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •