Home » RDBMS Server » Backup & Recovery » Setting Environment Variable in RMAN scripts
Setting Environment Variable in RMAN scripts [message #252329] Wed, 18 July 2007 11:36 Go to next message
ksintrakool
Messages: 20
Registered: July 2006
Location: Las Vegas
Junior Member
Hi All,

Is there a way to set environment variable in RMAN scripts?

I have a shell script to call a RMAN script which that RMAN script uses environment variable from my shell script.

Thank you,
Re: Setting Environment Variable in RMAN scripts [message #252360 is a reply to message #252329] Wed, 18 July 2007 12:46 Go to previous messageGo to next message
DreamzZ
Messages: 1666
Registered: May 2007
Location: Dreamzland
Senior Member
Whats you OS??
I have this for solaris you can try something like

>more ds_daily_backup.com
#!/bin/ksh
. $HOME/.profile_ds<<<<<<<contains all the environment variable setting + mount points etc

sqlplus oracle/dsoracle @$DS_SCRIPT/ds_ora_errors_report.sql >/dev/null 2>&1
$DS_SCRIPT/rman_maint_ds.com

$DS_SCRIPT/archive_switch_ds.sql
$DS_SCRIPT/ds_rman_bu.com

$DS_SCRIPT/mlog_errors_ds.com
$DS_SCRIPT/rman_maint_ds.com

[Updated on: Wed, 18 July 2007 12:47]

Report message to a moderator

Re: Setting Environment Variable in RMAN scripts [message #252421 is a reply to message #252329] Wed, 18 July 2007 15:25 Go to previous messageGo to next message
ksintrakool
Messages: 20
Registered: July 2006
Location: Las Vegas
Junior Member
Thank you DreamzZ

I might have to be more clear

My RMAN script is...

run{
# CONTROLFILE BACKUP SCRIPT
allocate channel t1 device type disk format '$BACKUP_DEST/CF-D_%d-id-%I_%f_%u.DB
F';
backup current controlfile;
sql 'alter database backup controlfile to trace';
sql "alter database backup controlfile to ''/$BACKUP_DEST/$CONTLFILE''";
release channel t1;
}

Is it possible for me to set BACKUP_DEST and $CONTLFILE in RMAN script? Wring now I pass these 2 varilables from an OS script.

Thanks,
Re: Setting Environment Variable in RMAN scripts [message #252432 is a reply to message #252421] Wed, 18 July 2007 16:06 Go to previous messageGo to next message
DreamzZ
Messages: 1666
Registered: May 2007
Location: Dreamzland
Senior Member
Quote:
Is it possible for me to set BACKUP_DEST and $CONTLFILE in RMAN script? Wring now I pass these 2 varilables from an OS script.


Yes

heres mine backup script sample which answers your question.

backup as compressed backupset database;
  sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';
  backup archivelog all format '$GAM_ORABACKUP/al_%U.bck';
  backup current controlfile
  tag = cf1
  format '$GAM_ORABACKUP/cf_%U.bck';


Its running succecfully with cron job.
Re: Setting Environment Variable in RMAN scripts [message #252435 is a reply to message #252329] Wed, 18 July 2007 16:56 Go to previous messageGo to next message
ksintrakool
Messages: 20
Registered: July 2006
Location: Las Vegas
Junior Member
Where do you set $GAM_ORABACKUP variable?

Are you passing this variable from an OS script?

I want to run my RMAN backup from the scheduler in the database which I can call RMAN script directly.
Re: Setting Environment Variable in RMAN scripts [message #252436 is a reply to message #252435] Wed, 18 July 2007 17:00 Go to previous messageGo to next message
DreamzZ
Messages: 1666
Registered: May 2007
Location: Dreamzland
Senior Member
I am using k shell,and i created the .sh file for Enviroment variables like this

omzesp01DS:/export/home/oracle$
>. .profile_gam
omzesp01ESPAM:/export/home/oracle$
>cd $GAM_SCRIPT
omzesp01ESPAM:/export/home/oracle/gam7.2/script$



>more gam_setup.sh
#!/bin/ksh
#
# This script contains common environment setup for the GAM system.
# Setting up 'HOME' and 'HOST' names for GAM Scripts
HOME=/export/home/oracle;
HOST="`hostname`";
export HOME
export HOST
#
# Directory structure
#
export GAM_DIR=$HOME/gam7.2
export GAM_DB=$HOME/gam7.2/db
export GAM_DBA=$HOME/gam7.2/dba
export GAM_SCRIPT=$HOME/gam7.2/script
export ESPGAM_DATA_DIR=$HOME/gam7.2/db_load
export ESPGAM_LOG_DIR=$HOME/gam7.2/db_load/log
export ESPGAM_ARCH_DIR=$HOME/gam7.2/db_load/archive

#
# ORACLE environment variables
#
export ORACLE_HOME=/opt/oracle/10.2.0
export ORACLE_AGENT_HOME=/opt/oracle/AGENT10.2.0/agent10g
export ORACLE_BASE=/opt/oracle/10.2.0
export ORACLE_SID=ESPAM
export LD_LIBRARY_PATH=/opt/app/ba/weblogic/lib/solaris/oci815_8
PATH=$ORACLE_HOME/bin:/jdk1.1.5/bin:/opt/SUNWspro/bin:/opt/SUNWvxva/bin:/opt/SUNWconn/bin:/:/usr/sbin:/usr/bin:/usr/ccs/bin:/opt/NSCPnav/bin:$PATH

# Changing this to use the 100s instead of the 200s!
# 8/23/05 therpin omzimp01
export ORA_DEV0=/u200
export ORA_DEV1=/u201
export ORA_DEV2=/u202
.
.
.

Re: Setting Environment Variable in RMAN scripts [message #252651 is a reply to message #252329] Thu, 19 July 2007 10:00 Go to previous messageGo to next message
ksintrakool
Messages: 20
Registered: July 2006
Location: Las Vegas
Junior Member
Thank you.

I am currently doing what you suggested on my scripts.
I would like to set a value to an enviornment variable in a RMAN script instread of setting it in an OS script.

Can I do something like "setenv BACKUP_DEST /.../..." in my RMAN script?
I know "sentenv BACKUP_DEST /.../..." doesn't work in RMAN script.
I have seen "send" commend in RMAN script, but it doesn't work for me.

Any more input are welcome.
Re: Setting Environment Variable in RMAN scripts [message #252661 is a reply to message #252651] Thu, 19 July 2007 10:24 Go to previous messageGo to next message
DreamzZ
Messages: 1666
Registered: May 2007
Location: Dreamzland
Senior Member
No,
Check this
http://www.oracle.com/technology/pub/articles/saternos_scripting.html

http://www.oracle-base.com/articles/misc/OracleShellScripting.php

http://oracle.ittoolbox.com/groups/technical-functional/oracle-db-l/unix-script-for-rman-to-perform-backup-723092
Re: Setting Environment Variable in RMAN scripts [message #252692 is a reply to message #252329] Thu, 19 July 2007 12:28 Go to previous message
ksintrakool
Messages: 20
Registered: July 2006
Location: Las Vegas
Junior Member
Thank you very much for all your inputs.
Previous Topic: I cant open Database. I tried almost all ways...
Next Topic: Restore datafile to new location on a new host
Goto Forum:
  


Current Time: Tue May 14 19:49:10 CDT 2024