Visit Our UNIX and Linux User Community

Script for Export backup!!

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script for Export backup!!
# 1  
Old 03-07-2012
MySQL Script for Export backup!!

Dear Team,

Can you please help me to write the script for export backup.
I've written some of the part and stuck in "if" condition Apprecatied if you help me.

Requirement:- Export backup completion sent the email if it is success (sent backup success email)or if fails (sent backup fails email).

My Shell Script:-

######################### START OF SCRIPT #########################
#Backup script by Export backup.
export HOST_NAME=`uname -n`
CDATE=`date +%d%m%Y`
export CDATE
echo $CDATE
echo Starting . > $LOGFILE
expdp system/password schemas=XXXXX directory=dump_dir DUMPFILE=$DMP_FILE LOGFILE=$LOG_FILE
echo Backup Completed. >> $LOGFILE
echo gzipping . >> $LOGFILE
echo gzipping Completed. >> $LOGFILE
#echo Deleting old files >> $LOGFILE
#find $EXPORT_PATH -type f -mtime +31 | xargs rm >> $LOGFILE
echo Delete Completed >> $LOGFILE
uuencode $LOGFILE expdb_$CDATE | mail -s "$HOST_NAME:$SID Export backup success on `CDATE`" $ADMIN_EMAIL
[oracle@testdb dump]$

Thank you,
Mohammed Fareed.

Last edited by Mohammed Fareed; 06-11-2012 at 07:39 AM..
Mohammed Fareed
# 2  
Old 03-07-2012
At which place do you want to check for success or failure? And on which criteria?
# 3  
Old 03-07-2012
Thanks for update Anchal, after this command runs (expdp system/manager1 schemas=PRODUCTION1 directory=dump_dir DUMPFILE=$DMP_FILE LOGFILE=$LOG_FILE) should check the logfile if it is success send success email if failed send backup failed.

Thank you.
Mohammed Fareed
# 4  
Old 03-07-2012
What if the command fails for some reason?
I am not aware with that command but I guess surely you could check with the exit status of the command.

After you run the command, you could do something like..

if [ $? -eq 0 ]; then
 #success mail
 #update logfile
 #fail mail
 #update logfile

Check the manual for your command to confirm the return values.
# 5  
Old 03-07-2012
AFAIR, oracle doesn't return the job completion status to the command line such that you can query $? after the expdp command.

So you have to refer to a line in the output file $LOG_FILE in your case for a pattern like
Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:
Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at 10:35
I googled for data pump and got this.
ORACLE-BASE - Oracle Database 10g Data Pump (expdp and impdp)

It is apparent that there is no "return value" as we want.

# 6  
Old 03-07-2012
Thanks for your update both of you.I tried with the given code it dozen work.
I also agree with Ananthp update.

My requirement is script should check export log($LOG_FILE)file should be checked if they found ("ORA-" "Linux-x86_64 Error" "stopped" "Failed" ) then sent backup failed email.

orelse sent backup successfull email. Hope you understand my needy.

Thank you.
Mohammed Fareed
# 7  
Old 03-07-2012
Ok. As per your requirement to check from logs,
you could grep the keywords like...

egrep -q "ORA-|Linux-x86_64 Error|stopped|Failed" $LOG_FILE
if [ $? -ne 0 ]; then
 #success mail
 #update logfile
 #fail mail
 #update logfile

Previous Thread | Next Thread
Test Your Knowledge in Computers #881
Difficulty: Medium
One many threat vectors to a modern SCADA system is the threat of unauthorized access to the control software,
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Export Error in Shell script

All, While executing the bellow commnad after the sed, awk command to export the value to, i am getting the fallowing error. line="_AABBB.EEEEEEE.LOG4JDISPLAY.PATH_=/apps/opt/abcde/pdstdsd/esapp/apadsfasdf/logadsfasdf.xml" keystring=`echo $line | awk -F"=" '{ print $1 }'`... (1 Reply)
Discussion started by: jothi basu
1 Replies

2. Shell Programming and Scripting

Help with Backup Shell Script for Network Device Configuration backup

HI all, im new to shell scripting. need your guidence for my script. i wrote one script and is attached here Im explaining the requirement of script. AIM: Shell script to run automatically as per scheduled and backup few network devices configurations. Script will contain a set of commands... (4 Replies)
Discussion started by: saichand1985
4 Replies

3. Shell Programming and Scripting

export repository shell script

Hi Forum, I have script to export he Siebel repository. My requirment is to have a shell script in place so when placed in it in a cron it should generate the repsoitory dat file on date basis. Script for export: repimexp /a E /c UCM_ES_DEV2_DSN /u sadmin /p SADMIN /d siebel /r... (4 Replies)
Discussion started by: nuthakki
4 Replies

4. Shell Programming and Scripting

rsync backup mode(--backup) Are there any options to remove backup folders on successful deployment?

Hi Everyone, we are running rsync with --backup mode, Are there any rsync options to remove backup folders on successful deployment? Thanks in adv. (0 Replies)
Discussion started by: MVEERA
0 Replies

5. Shell Programming and Scripting

Export from perl script

Hi, Want to initaite the Oracle's Export utility from the perl script,but getting error as mentioned below: Script #!/usr/bin/perl -w my $username="system"; my $password = "manager"; my $tns = "DBLOCAL"; exp $username/$password@$tns Error $ ./ Array found where... (4 Replies)
Discussion started by: milink
4 Replies

6. Shell Programming and Scripting

Use of export from a shell script..

Hi All, I am facing a problem while trying to export path variables from a script. Here's my situation 1. I have a script in which i have defined all the path variables to be exported: export ORACLE_HOME=/path/to/bin/ export NG_USER_HOME=/path/to/bin/ etc.... 2. I have another shell... (4 Replies)
Discussion started by: raghu_shekar
4 Replies

7. Shell Programming and Scripting

How to export an array to perl script?

hi all...... i want to use an array ,declared in bash, in embedded perl script. is there any way to export whole array so that i can use it '$ENV{}' or something.. thanx in advance!! regards, prayush (1 Reply)
Discussion started by: tprayush
1 Replies

8. UNIX for Dummies Questions & Answers

export script commands with xterm

I am attempting to write a shell script that runs a program which generates data and then runs another program to plot the data. The problem is that I need the plotting to take place in a different terminal window that stays open after the plotting has finished. I have experimented 'xterm -e '... (1 Reply)
Discussion started by: chris2051
1 Replies

9. Shell Programming and Scripting

script to export variables

Hi, I am a newbie to unix as well as scripting. I need to write a script, which on execution sets the necessay oracle variables. Can someone help me out as to how to proceed? also can u suggest good tutorial for bash/shell scripting? thanks (1 Reply)
Discussion started by: aboxilica
1 Replies

10. UNIX for Advanced & Expert Users

export UNIX95=1 in a script??

Hi, I have following script. It has a line export UNIX95=1 What does UNIX95 suggest? If I donot export UNIX95=1 , I get error "illegale option -o" for ps command. man ps donot show -o option. Any pointers?? Thanks in advance, -Ashish (2 Replies)
Discussion started by: shriashishpatil
2 Replies

Featured Tech Videos