Review Cold backup script [message #202102] |
Wed, 08 November 2006 03:40 |
prashanth_gs
Messages: 67 Registered: November 2005 Location: chennai
|
Member |
|
|
Hello all,
I have prepared cold backup script (user managed) for the new database going to be created.
Please review my script that if syntax is correct and if it works???
#!/bin/bash
export ORACLE_HOME=/oracle/app/oracle/product/10gr2
export ORACLE_SID=UATGDB
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SCRIPTS=/oradata4/oradata/uatgdb/scripts
export CLD_DATAFILE_DIR=/oradata4/oradata/uatgdb/coldbackup/datafile_dir
export CLD_REDOLOGFILE_DIR=/oradata4/oradata/uatgdb/coldbackup/redologfile_dir
export CLD_CONTROLFILE_DIR=/oradata4/oradata/uatgdb/coldbackup/controlfile_dir
export CLD_TEMPFILE_DIR=/oradata4/oradata/uatgdb/coldbackup/tempfile_dir
export logfile=/oradata4/oradata/uatgdb/coldbackup.log
DD=`date +%m%d%H%M`
set echo off
set pause off
set feed off
set head off
spool cold_backup.lst
sqlplus " / as sysdba"
shutdown immediate;
select 'cp ' ||NAME|| '$CLD_DATAFILE_DIR/${DD}_1,$CLD_DATAFILE_DIR/${DD}_2,$CLD_DATAFILE_DIR/${DD}_3,$CLD_DATAFILE_DIR/${DD}_4,$CLD_DATAFILE_DIR/${DD}_5 from v$datafile;
select 'cp ' ||Name|| ' $CLD_TEMPFILE_DIR/${DD}_1,$CLD_TEMPFILE_DIR/${DD}_2,$CLD_TEMPFILE_DIR/${DD}_3,$CLD_TEMPFILE_DIR/${DD}_4,$CLD_TEMPFILE_DIR/${DD}_5 from v$tempfile;
select 'cp ' ||Name|| ' $CLD_CONTROLFILE_DIR/${DD}_1,$CLD_CONTROLFILE_DIR/${DD}_2,$CLD_CONTROLFILE_DIR/${DD}_3,$CLD_CONTROLFILE_DIR/${DD}_4,$CLD_CONTROLFILE_ DIR/${DD}_5 from v$controlfile;
select 'cp ' ||Member|| ' $CLD_REDOLOGFILE_DIR/${DD}_1,$CLD_REDOLOGFILE_DIR/${DD}_2,$CLD_REDOLOGFILE_DIR/${DD}_3,$CLD_REDOLOGFILE_DIR/${DD}_4,$CLD_REDOLOGFILE_ DIR/${DD}_5from v$logfile;
startup
spool off
#######REMOVING OLD FILES#####
find $CLD_DATAFILE_DIR -mtime +3 -type f -exec rm -f {} \;
find $CLD_REDOLOGFILE_DIR -mtime +3 -type f -exec rm -f {} \;
find $CLD_CONTROLFILE_DIR -mtime +3 -type f -exec rm -f {} \;
find $CLD_TEMPFILE_DIR -mtime +3 -type f -exec rm -f {} \;
find $logfile -mtime +3 -type f -exec rm -f {} \;
:q
Database : Oracle 10gR2
OS : SUN 5.8
Thanks and Regards,
Prashanth
|
|
|
|
Re: Review Cold backup script [message #202113 is a reply to message #202103] |
Wed, 08 November 2006 04:12 |
prashanth_gs
Messages: 67 Registered: November 2005 Location: chennai
|
Member |
|
|
Thanks a lot for immediate response.
I added following lines in my script after your comments:
#select 'cp ' ||Name|| ' $CLD_CONTROLFILE_DIR/${DD}_1,$CLD_CONTROLFILE_DIR/${DD}_2,$CLD_CONTROLFILE_DIR/${DD}_3,$CLD_CONTROLFILE_DIR/${DD}_4,$CLD_CONTROLFILE_ DIR/${DD}_5
alter database backup controlfile to '$CLD_CONTROLFILE_DIR/${DD}_1,$CLD_CONTROLFILE_DIR/${DD}_2,$CLD_CONTROLFILE_DIR/${DD}_3,$CLD_CONTROLFILE_DIR/${DD}_4,$CLD_CONTROLFILE _DIR/${DD}_5;
alter database backup controlfile to trace;
select 'cp ' ||$ORACLE_HOME/dbs/inituatgdb.ora|| '$CLD_INITFILE_DIR_DIR/${DD}_1,$CLD_INITFILE_DIR_DIR/${DD}_2,$CLD_INITFILE_DIR_DIR/${DD}_3,$CLD_INITFILE_DIR_DIR/${DD}_4,$CLD_INITFIL E_DIR_DIR/${DD}_5' from dual;
If any thing wrong please inform me.
Thanks and Regards,
Prashanth
|
|
|
|