If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Can Some one can help me in Shell script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-15-08, 14:57
smith43017 smith43017 is offline
Registered User
 
Join Date: Sep 2006
Posts: 92
Can Some one can help me in Shell script

We have database name Progress.

We will restore prod back files to UserServer on Sunday. Except all other days We will keep apply AI(trsaction log files kind in db2) files of that day. I have appy the log files in SEQUENTIAL order by timestamp which is part of file name.

*********************************

#set -x
DATE=`date "+%y%m%d%H%M%S"`

########## MAIN FUNCTION
myfunc ()
{
ls -ltr /archive/testdb/|grep progress|cut -c67-78>unc
while read ai
do
echo $ai is getting Verifified by If clause
if [ "${ai}" -le "${DATE}" ]; then
echo $ai "<" $DATE
$DLC/bin/rfutil dbname -C roll forward -a /archive/testdb/$ai
#####I will write another if clause for check the command run sucessfully or not####
else
echo ""
echo "Can't apply Log File $ai is >= 080214121500"
fi
done < unc
rm unc
}

################ MAIN

date > wekday
while read d1 rest_of_file
do
wd=${d1%}
case $wd in
Mon)
echo $wd;
myfunc $DATE ;;
Tue)
echo $wd;
myfunc $DATE ;;
Wed)
echo $wd;
myfunc $DATE ;;
Thu)
echo $wd;
myfunc $DATE ;;
Fri)
echo $wd;
myfunc $DATE ;;
Sat)
echo $wd;
myfunc $DATE ;;
Sun)
echo "Full Restore"
echo $wd;;
*)
print "Invalid day for Applying AI files To Report Server" ;;
esac
done < wekday
rm wekday



i wrote this one. Can Some can give me some more suggestions

Last edited by smith43017; 02-15-08 at 15:09.
Reply With Quote
  #2 (permalink)  
Old 02-15-08, 17:22
smith43017 smith43017 is offline
Registered User
 
Join Date: Sep 2006
Posts: 92
It's not working. Some How I don't know where I am doing mistake can some body can help or guide me. Please
Reply With Quote
  #3 (permalink)  
Old 02-18-08, 02:17
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
What error message do you get?
What does the log filenames look like?
You say restore prod to user but the ls is on test
ls -ltr /archive/testdb

You seem to make thing unnecessary complex
Code:
wd=`date +%a`
if [ "$wd" = "Sun" ]
then 
  echo "Full Restore"
else
  echo "Log restore"
fi
It seems you do not specify the file name for the log restore
ls -ltr /archive/testdb/|grep progress|cut -c67-78>unc
while read ai
...
$DLC/bin/rfutil dbname -C roll forward -a /archive/testdb/$ai
And you prbably don't need the grep and cut commands
And on Tue you don't want to reload Mon logs do you?
Reply With Quote
  #4 (permalink)  
Old 02-19-08, 08:38
smith43017 smith43017 is offline
Registered User
 
Join Date: Sep 2006
Posts: 92
Thank for replying pdreyer

Log filenames are like this


ai.080212001500
ai.080212061500
ai.080212121500
ai.080212181501
ai.080212181523
ai.080213001500
ai.080213061500
ai.080213121500
ai.080213181500
ai.080213181524
ai.080214001500
ai.080214061500
ai.080214121500
ai.080214181501
ai.080214181521
ai.080215001501
ai.080215061500
ai.080215121501


And Applying logs failed. I need to determin which log is first one and after that sequential order By time.

Error message is Inccorect log file trying to apply.

Last edited by smith43017; 02-19-08 at 08:52.
Reply With Quote
  #5 (permalink)  
Old 02-19-08, 08:45
smith43017 smith43017 is offline
Registered User
 
Join Date: Sep 2006
Posts: 92
Thanks for replay pdreyer .

The reseson I kept all the days is, I need to add some more functionality on perticular week day.

Quote:
Originally Posted by pdreyer
What error message do you get?
What does the log filenames look like?
You say restore prod to user but the ls is on test
ls -ltr /archive/testdb

I coped in my test directory I am trying from ther. I don't want touch prod log files.


You seem to make thing unnecessary complex
Code:
wd=`date +%a`
if [ "$wd" = "Sun" ]
then 
  echo "Full Restore"
else
  echo "Log restore"
fi
It seems you do not specify the file name for the log restore
ls -ltr /archive/testdb/|grep progress|cut -c67-78>unc
while read ai

You are right, I modified script. and posting in next post
...
$DLC/bin/rfutil dbname -C roll forward -a /archive/testdb/$ai
And you prbably don't need the grep and cut commands

What are the best options to get time time stamp and compare.
And on Tue you don't want to reload Mon logs do you?

Yes On every weekday I need to apply all Monday, Tue, Wed ... apply and then previous day logs as last set.

Last edited by smith43017; 02-19-08 at 08:53.
Reply With Quote
  #6 (permalink)  
Old 02-19-08, 08:50
smith43017 smith43017 is offline
Registered User
 
Join Date: Sep 2006
Posts: 92
Still getting the same error.


#set -x
DATE=`date "+%y%m%d%H%M%S"`

########## MAIN FUNCTION
myfunc ()
{
ls -ltr /archive/testdb/|grep progress|cut -c67-78>unc
while read ai
do
echo $ai is getting Verifified by If clause
#if [ "${ai}" -le "${DATE}" ]; then
if [ "${ai}" -le 080214121500 ]; then
echo $ai "<" 080214121500
#echo $ai "<" $DATE
$DLC/bin/rfutil dbname -C roll forward -a /archive/testdb/ai.$ai
else
echo ""
echo "Can't apply Log File $ai is >= 080214121500"
fi
done < unc
rm unc
}
################ MAIN

date > wekday
while read d1 rest_of_file
do
wd=${d1%}
case $wd in
Mon)
echo $wd;
myfunc $DATE ;;
Tue)
echo $wd;
myfunc $DATE ;;
Wed)
echo $wd;
myfunc $DATE ;;
Thu)
echo $wd;
myfunc $DATE ;;
Fri)
echo $wd;
myfunc $DATE ;;
Sat)
echo $wd;
myfunc $DATE ;;
Sun)
echo "Full Restore"
echo $wd;;
*)
print "Invalid day for Applying AI files To Report Server" ;;
esac
done < wekday
rm wekday

Last edited by smith43017; 02-19-08 at 12:02.
Reply With Quote
  #7 (permalink)  
Old 02-19-08, 08:58
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Stupid question, maybe: doesn't your DBMS figure out by itself which backup and log files it needs?
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #8 (permalink)  
Old 02-19-08, 09:03
smith43017 smith43017 is offline
Registered User
 
Join Date: Sep 2006
Posts: 92
Can somebody can have look at this let me now what I am doing wrong
Reply With Quote
  #9 (permalink)  
Old 02-19-08, 09:10
smith43017 smith43017 is offline
Registered User
 
Join Date: Sep 2006
Posts: 92
It knwos Which file It needs but If we pass location It didn't apply in right manner and sequential order. When DB2 if mentioned location and end of the log files is good enough. Manuvally needs to apply the log file.

Thanks For replay Stolze
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On