Home

Thursday, December 5, 2013

Logical Backup Informix Database menggunakan Shell Scripts

Dibawah ini contoh sederhana membuat backup menu menggunakan Shell Scripts , sebagai contoh scripts di bawah ini di gunakan untuk membackup data logical Informix Database (Versi 10) ke dalam Tape :

Informix Dynamic Servers Logical Backup 
-----------------------------------------------
trap '' 2
TRUE=1
FALSE=0

TEST=$TRUE

wait_running()
{
        printf "process still shutting down please wait ."
        while [ 1 ];
        do
                TAPE_RUN=`ps -ef | grep "ontape"`
                F_CHECK=`echo $TAPE_RUN | grep "ontape -c"`
                if [ "$F_CHECK" = "" ];then
                        echo
                        echo "process is shutdown ...."
                        break
                fi
                printf "."
                sleep 2
        done
}

running()
{
        IS_FOUND=`ps -ef | grep "ontape"`
        SD_CHECK=`echo $IS_FOUND | grep "ontape -c"`
        if [ "$SD_CHECK" != "" ];then
                echo "-----------------------------------------------"
                echo "STATUS: Logical Backup Is Currently Enabled...."
                echo "-----------------------------------------------"
        else
                echo "------------------------------------------------"
                echo "STATUS: Logical Backup Is Currently Disabled...."
                echo "------------------------------------------------"
        fi
        echo "What would you like to do ......"
}


clear
while [ $TEST ];
do
        echo "*-------------------------------------------"
        echo "*  \033[5m   Logical Backup Menu  \033[0m   *"
        echo "*------------------------------------------*"
        echo "*                                          *"
        echo "*  \033[5m1. Enable Logical Backup  \033[0m              *"
        echo "*  \033[5m2. Disable Logical Backup \033[0m              *"
        echo "*  \033[5m3. Quit                   \033[0m              *"
        echo "*                                          *"
        echo "*-------------------------------------------"
        running
        printf "logback >>: "
        read OPT

        if [ "$OPT" = "1" ];then
                clear
                echo "\033[1m  \033[31m   READ MESSAGE BELOW TO SEE RESULT OF SCRIPT \033[0m \033[0m"
                sudo su - endbbkp
                echo "\033[1m  \033[31m   OPTION [1] SELECTED ... backup enabled & will start on the next cron job \033[0m \0
33[0m"
        elif [ "$OPT" = "2" ];then

                clear
                echo "\033[1m  \033[31m   READ MESSAGE BELOW TO SEE RESULT OF SCRIPT \033[0m \033[0m"
                sudo su - disdbbkp
                echo "please wait ..... "
                wait_running
                echo "\033[1m  \033[31m   OPTION [2] SELECTED ... Please Select an option from below \033[0m \033[0m"
        elif [ "$OPT" = "3" ];then

                echo "Thankyou for using the system ...."
                echo "exiting ...."
                exit
        else
                clear
                echo "--------------------------------------------"
                echo "your option is not valid please select again"
                echo "--------------------------------------------"
        fi
done

No comments:

Post a Comment