Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Backup Script

Re: Backup Script

From: Karsten Farrell <kfarrell_at_belgariad.com>
Date: Wed, 06 Aug 2003 20:06:20 GMT
Message-ID: <MPG.199aff9460f5fe6f98982b@news.la.sbcglobal.net>


Hi Hari Om, thanks for writing this:
> I have a question on the Cold Backup Scripts. I was reading a book and
> it showed how to use scripts to automate BACKUP. Here is a sample:
> --------------------------------------------------------------------
> #!/bin/ksh
> ORACLE_SID=$1
> export ORACLE_SID
> export ORAENV_ASK=NO
> BACKUP_DIR=/test01/app/oracle
> . oraenv
> sqlplus -s system/remorse << EOF
> set head off feed off echo off trimspool on linesize 200
> spool /u01/app/oracle/dba/cold_backup.ksh
> select 'cp' || file_name || '{$BACKUP_DIR}' from sys.dba_data_files;
> select 'cp' || name || '{$BACKUP_DIR}' from v$controlfile;
> select 'cp' || member || '{$BACKUP_DIR}' from v$logfile;
> spool off;
> exit;
> EOF
> --------------------------------------------------------------------
>
> My question is with reference to line 6 (. oraenv) and Line 7
> (sqlplus...)
> What does Line 6 do? What is . oraenv used for?
> What does SQLPLUS with '-s" option do?
>
> I am a newbie and so please excuse my ignorance on this topic. Where
> can I find more startup scripts on Oracle DB?
>
> Thanks!
>

The dot means run the oraenv program, which just happens to be a shell script, whose location may vary with o/s (/usr/local/bin on my system).

It sets up the Oracle environment ... things like including Oracle in the PATH and such. Since cron jobs don't run your ksh .profile, you need to make sure the environment is set up beforehand. I normally set ORACLE_SID, ORACLE_HOME, and PATH manually instead of calling oraenv ... but that's just my personal preference (YMMV) ... and then I don't have to include the path to oraenv in the PATH variable.

I assume this is a "simplified" script since it doesn't check for a valid SID being entered on the command line ($1). A simple grep of the oratab file will probably suffice.

-- 
[:%s/Karsten Farrell/Oracle DBA/g]
Received on Wed Aug 06 2003 - 15:06:20 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US