LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-31-2008, 05:08 AM   #1
maooah
Member
 
Registered: Dec 2007
Posts: 44

Rep: Reputation: 15
script explaination


hi all

could any one explain the following script

****************hot_database_backup.sh*******************

CUSER=`id |cut -d"(" -f2 | cut -d ")" -f1`

# ---------------------------------------------------------------------------
# Put output in <this file name>.out. Change as desired.
# Note: output directory requires write permission.
# ---------------------------------------------------------------------------

RMAN_LOG_FILE=${0}.out

if [ -f "$RMAN_LOG_FILE" ]
then
rm -f "$RMAN_LOG_FILE"
fi

echo >> $RMAN_LOG_FILE
chmod 666 $RMAN_LOG_FILE

echo Script $0 >> $RMAN_LOG_FILE
echo ==== started on `date` ==== >> $RMAN_LOG_FILE
echo >> $RMAN_LOG_FILE

ORACLE_HOME=/prod_ora/proddb/9.2.0
export ORACLE_HOME

ORACLE_SID=prod
export ORACLE_SID

ORACLE_USER=proddb

TARGET_CONNECT_STR=/

RMAN=$ORACLE_HOME/bin/rman

NB_ORA_CLIENT=proddb

echo >> $RMAN_LOG_FILE
echo "RMAN: $RMAN" >> $RMAN_LOG_FILE
echo "ORACLE_SID: $ORACLE_SID" >> $RMAN_LOG_FILE
echo "ORACLE_USER: $ORACLE_USER" >> $RMAN_LOG_FILE
echo "ORACLE_HOME: $ORACLE_HOME" >> $RMAN_LOG_FILE

echo >> $RMAN_LOG_FILE
echo "NB_ORA_FULL: $NB_ORA_FULL" >> $RMAN_LOG_FILE
echo "NB_ORA_INCR: $NB_ORA_INCR" >> $RMAN_LOG_FILE
echo "NB_ORA_CINC: $NB_ORA_CINC" >> $RMAN_LOG_FILE
echo "NB_ORA_SERV: $NB_ORA_SERV" >> $RMAN_LOG_FILE
echo "NB_ORA_POLICY: $NB_ORA_POLICY" >> $RMAN_LOG_FILE


echo >> $RMAN_LOG_FILE

if [ "$NB_ORA_FULL" = "1" ]
then
echo "Full backup requested" >> $RMAN_LOG_FILE
BACKUP_TYPE="INCREMENTAL LEVEL=0"

elif [ "$NB_ORA_INCR" = "1" ]
then
echo "Differential incremental backup requested" >> $RMAN_LOG_FILE
BACKUP_TYPE="INCREMENTAL LEVEL=1"

elif [ "$NB_ORA_CINC" = "1" ]
then
echo "Cumulative incremental backup requested" >> $RMAN_LOG_FILE
BACKUP_TYPE="INCREMENTAL LEVEL=1 CUMULATIVE"

elif [ "$BACKUP_TYPE" = "" ]
then
echo "Default - Full backup requested" >> $RMAN_LOG_FILE
BACKUP_TYPE="INCREMENTAL LEVEL=0"
fi



CMD_STR="
ORACLE_HOME=$ORACLE_HOME
export ORACLE_HOME

ORACLE_SID=$ORACLE_SID
export ORACLE_SID

NB_ORA_CLIENT=$NB_ORA_CLIENT
export NB_ORA_CLIENT

$RMAN target $TARGET_CONNECT_STR catalog rman/rman@rcat msglog $RMAN_LOG_FILE append << EOF
RUN {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
BACKUP
$BACKUP_TYPE
SKIP INACCESSIBLE
TAG hot_db_bk_level0
FILESPERSET 50
# recommended format
FORMAT 'bk_%s_%p_%t'
DATABASE;
sql 'alter system archive log current';
RELEASE CHANNEL ch00;
# backup all archive logs
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
BACKUP
filesperset 50
FORMAT 'al_%s_%p_%t'
ARCHIVELOG ALL DELETE INPUT;
RELEASE CHANNEL ch00;

ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
BACKUP
# recommended format
FORMAT 'cntrl_%s_%p_%t'
CURRENT CONTROLFILE;
RELEASE CHANNEL ch00;
}
EOF
"
# Initiate the command string

if [ "$CUSER" = "root" ]
then
su - $ORACLE_USER -c "$CMD_STR" >> $RMAN_LOG_FILE
RSTAT=$?
else
/usr/bin/sh -c "$CMD_STR" >> $RMAN_LOG_FILE
RSTAT=$?
fi

# ---------------------------------------------------------------------------
# Log the completion of this script.
# ---------------------------------------------------------------------------

if [ "$RSTAT" = "0" ]
then
LOGMSG="ended successfully"
else
LOGMSG="ended in error"
fi

echo >> $RMAN_LOG_FILE
echo Script $0 >> $RMAN_LOG_FILE
echo ==== $LOGMSG on `date` ==== >> $RMAN_LOG_FILE
echo >> $RMAN_LOG_FILE

exit $RSTAT


************************logfile contains******************
Script /prod_ora/proddb/9.2.0/rman/hot_database_backup.sh
==== started on Sat May 10 17:59:05 AST 2008 ====


RMAN: /prod_ora/proddb/9.2.0/bin/rman
ORACLE_SID: prod
ORACLE_USER: proddb
ORACLE_HOME: /prod_ora/proddb/9.2.0

NB_ORA_FULL: 1
NB_ORA_INCR: 0
NB_ORA_CINC: 0
NB_ORA_SERV: darapps
NB_ORA_POLICY: PRODDATA_Daily

Full backup requested
Sun Microsystems Inc. SunOS 5.9 Generic May 2002
RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19> 20> 21> 22> 23> 24> 25> 26> 27> 28> 29> 30> 31> 32> 33> 34> RMAN> get database: PROD (DBID=17200796)
connected to recovery catalog database

RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19> 20> 21> 22> 23> 24> 25> 26> 27> 28> 29> 30> 31> 32> 33> 34>
allocated channel: ch00
channel ch00: sid=119 devtype=SBT_TAPE
channel ch00: VERITAS NetBackup for Oracle - Release 6

so on
***************************end***************************

waiting for valuable reply

Regards
 
Old 05-31-2008, 07:22 AM   #2
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware 14.2
Posts: 2,815
Blog Entries: 1

Rep: Reputation: 261Reputation: 261Reputation: 261
What part don't you understand? If it's the whole thing, then I suggest you start here --> http://tldp.org/LDP/abs/html/abs-guide.html. I doubt anyone has time to explain the whole script to you.
 
Old 05-31-2008, 07:33 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
****************hot_database_backup.sh*******************
It appears to be a script for backing up a database.....

Seriously, why would you expect anyone to go through that entire script explaining to you how it works?
 
Old 05-31-2008, 07:37 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
At least you can try to explain what this script is intended for, that is where did you got it and what are you trying to accomplish. What about if I asked "what the following script do?"
Code:
*-?/[0-9]/*$$ && echo yes
 
Old 06-01-2008, 01:30 AM   #5
maooah
Member
 
Registered: Dec 2007
Posts: 44

Original Poster
Rep: Reputation: 15
hi all

thanks weibullguy for pointing me to right direction

Regards
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Userdel command , Need explaination srihariv Linux - General 4 03-07-2008 02:57 AM
Again I need your explaination to understand a program. Gins Programming 7 03-24-2006 04:19 PM
Squid process. need explaination! mrpc_cambodia Red Hat 5 10-11-2004 11:18 AM
Explaination Of DNS Terms Joe_Astor Linux - Networking 7 04-11-2004 02:56 AM
Is there an In dept explaination of 2.4.22 Kernal options? jimdaworm Linux - Newbie 2 11-15-2003 02:51 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration