Sponsored Content
Full Discussion: flags to avoid restart
Top Forums Shell Programming and Scripting flags to avoid restart Post 302705803 by crazy_max on Tuesday 25th of September 2012 02:13:54 PM
Old 09-25-2012
flags to avoid restart

hello all,

i have the below script that we used to backup our DB using oracle's utility called RMAN. This has been working fine, but the issue is when the backup fails and we re-start it, it backups the whole thing again. Example.

lets say i have 5 database on my system(db1,db2,db3,db4,db5) and we use below script which loops for a file called /etc/oratab which has my DB names in it. If the script completes successfully we have no issue. But lets say db1 and db2 backup was successful and db3 backup fails and db4 and db5 backup was good. NOW LETS SAY i want restart by backup as DB3 backup failed...it is going to backup db1, db2, db3,db4,db5 all of them all again and that i was i want to avoid...the script needs to put some flag or something were it knows only db3 has failed and that is the only one that needs to be backed up...

how can i accomplish that? below is the script....
Code:
umask o+w
LogMsg()
{
echo "`date '+%Y%m%d.%H%M%S'` :: $*" >> $RMAN_LOG_FILE
}

##########################################################################
# Calls LogMsg and exits with failure
##########################################################################
LogAndFail()
{
LogMsg "$*"
exit 1
}

TODAY=`date '+%C%y_%m_%d_%H_%M'`; export TODAY
export ORATAB=/etc/oratab

###START OF LOOP
for db in `egrep -i ":NBU" $ORATAB | grep -v "^#" | grep -v "\*" | cut -d":" -f1 | sort | uniq`
do
  echo "processing database: $db"
  export ORACLE_SID=$db

  export RMAN_LOG_FILE=/oracle/sqlutils/logs/RMAN_bkp_${ORACLE_SID}_${TODAY}.log

  export ORACLE_HOME=`grep -i $ORACLE_SID: ${ORATAB}|grep -v "^#" | cut -f2 -d:`
  export PATH=$ORACLE_HOME/bin:$PATH

$ORACLE_HOME/bin/rman <<EOF >> $LOG
connect catalog rman/password@reocverycatalog
connect target /
run
{
allocate channel t1 type disk;
allocate channel t2 type disk;
backup database plus archivelog;
RELEASE CHANNEL t1;
allocate channel for maintenance type disk;
show all;
report obsolete;
delete noprompt expired backup;
delete noprompt obsolete;
crosscheck backup;
crosscheck archivelog all;
release channel;
}
EOF
exit

 RSTAT=$?

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

  if [ "$RSTAT" = "0" ]
  then
    LOGMSG="Backup successfully $ORACLE_SID"
    echo $LOGMSG|mailx -s "BACKUP Status ..." abc@company.com
  else
    LOGMSG="Backup error $ORACLE_SID"
    echo $LOGMSG|mailx -s "BACKUP Status ..." abc@company.com
  fi

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

######   end of loop #######
done

exit $RSTAT


Last edited by Corona688; 09-25-2012 at 04:04 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

if flags

Hi folks. I'm just starting to teach myself shell scripting and am having some trouble with an if statement. I am working with a directory where only one file will reside at a time and need to evaluate if this file is compressed to determine subsequent steps. I'm using echo for testing purposes.... (2 Replies)
Discussion started by: kristy
2 Replies

2. Shell Programming and Scripting

makefile not taking -D flags

Hi, I found this strange behaviour while using one of the makefiles. Here is the snippet of the unix.mak that is necessary for this context SO = SvSocket.o SvStmt.o SvOdbcWrapper.o \ OdbcCallReader.o MgrCalls.o OdbcSvProxy.o \ OdbcSvApp.o... (4 Replies)
Discussion started by: vino
4 Replies

3. AIX

question concerning Grep flags

Hey all. I am trying to find a process that is running and appending it to a file. The comman I am using is ps -eaf |grep tctl. The problem is, it returns the tctl process as well as the grep process that I just ran. Is there a flag that will prevent the command from returning itself? ... (2 Replies)
Discussion started by: jalge2
2 Replies

4. Shell Programming and Scripting

Making flags for my script

I have no idea how to make my own flags. (6 Replies)
Discussion started by: rcunn87
6 Replies

5. UNIX for Advanced & Expert Users

Processes Communication Only with flags!

hello everybody and a happy new year! i am trying the client-server model...i have no problem with sockets etc... especially for server:there is a father who is listening for TCP connections from clients,the later send commands which parent shares to his children. then children execute... (1 Reply)
Discussion started by: vaggelakis
1 Replies

6. UNIX for Dummies Questions & Answers

Question about Setting Flags

I have a script which will look for a test folder under the parent directory. If the folder contains test folder then create the same directory structure in other remote machine. Once the directories are created then transfer all the contents of that test folder. this is what i am doing :- ... (2 Replies)
Discussion started by: chris1234
2 Replies

7. IP Networking

arp output (flags)

I'm running an arp -an on a Solaris 10 box. We're using IPMP. One of the systems is not able to see a host on the same network. The only difference between the two systems (one is having a problem, the other isn't) at least so far is the output of arp: # arp -an | grep 224.55 e1000g5... (1 Reply)
Discussion started by: BOFH
1 Replies

8. Shell Programming and Scripting

Need help to identify the flags by scripts.

Hi, I have two different scripts sap_ftp.sh and sap_ftp_dd.sh which are running continously in background. I am using another script called start.sh to launch these two scripts. Either one script will process files at a time . During that time other script will sleep.. Each script will... (1 Reply)
Discussion started by: bhargav20
1 Replies

9. UNIX for Dummies Questions & Answers

WHat are flags?

Can anybody actually tell, what is flag? I know they are termed as permission flags and various others. Please explain (3 Replies)
Discussion started by: nixhead
3 Replies

10. UNIX for Dummies Questions & Answers

Ifconfig Flags

Hi there, I need your help in understanding the below Solaris 10 ifconfig output; athnetspns02>ifconfig -a lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 e1000g0:... (2 Replies)
Discussion started by: wthomas
2 Replies
NPM-RUN-SCRIPT(1)                                                                                                                NPM-RUN-SCRIPT(1)

NAME
npm-run-script - Run arbitrary package scripts SYNOPSIS
npm run-script <command> [--silent] [-- <args>...] alias: npm run DESCRIPTION
This runs an arbitrary command from a package's "scripts" object. If no "command" is provided, it will list the available scripts. run[-script] is used by the test, start, restart, and stop commands, but can be called directly, as well. When the scripts in the package are printed out, they're separated into lifecycle (test, start, restart) and directly-run scripts. As of ` https://blog.npmjs.org/post/98131109725/npm-2-0-0, you can use custom arguments when executing scripts. The special option -- is used by getopt https://goo.gl/KxMmtG to delimit the end of the options. npm will pass all the arguments after the -- directly to your script: npm run test -- --grep="pattern" The arguments will only be passed to the script specified after npm run and not to any pre or post script. The env script is a special built-in command that can be used to list environment variables that will be available to the script at run- time. If an "env" command is defined in your package, it will take precedence over the built-in. In addition to the shell's pre-existing PATH, npm run adds node_modules/.bin to the PATH provided to scripts. Any binaries provided by locally-installed dependencies can be used without the node_modules/.bin prefix. For example, if there is a devDependency on tap in your package, you should write: "scripts": {"test": "tap test/*.js"} instead of "scripts": {"test": "node_modules/.bin/tap test/*.js"} to run your tests. The actual shell your script is run within is platform dependent. By default, on Unix-like systems it is the /bin/sh command, on Windows it is the cmd.exe. The actual shell referred to by /bin/sh also depends on the system. As of ` https://github.com/npm/npm/releases/tag/v5.1.0 you can customize the shell with the script-shell configuration. Scripts are run from the root of the module, regardless of what your current working directory is when you call npm run. If you want your script to use different behavior based on what subdirectory you're in, you can use the INIT_CWD environment variable, which holds the full path you were in when you ran npm run. npm run sets the NODE environment variable to the node executable with which npm is executed. Also, if the --scripts-prepend-node-path is passed, the directory within which node resides is added to the PATH. If --scripts-prepend-node-path=auto is passed (which has been the default in npm v3), this is only performed when that node executable is not found in the PATH. If you try to run a script without having a node_modules directory and it fails, you will be given a warning to run npm install, just in case you've forgotten. You can use the --silent flag to prevent showing npm ERR! output on error. You can use the --if-present flag to avoid exiting with a non-zero exit code when the script is undefined. This lets you run potentially undefined scripts without breaking the execution chain. SEE ALSO
o npm help 7 scripts o npm help test o npm help start o npm help restart o npm help stop o npm help 7 config January 2019 NPM-RUN-SCRIPT(1)
All times are GMT -4. The time now is 07:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy