Home » RDBMS Server » Backup & Recovery » Review Cold backup script
Review Cold backup script [message #202102] Wed, 08 November 2006 03:40 Go to next message
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 #202103 is a reply to message #202102] Wed, 08 November 2006 03:44 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
You are missing your spfile (or initsid.ora if that matters). I would also backup the traced (text) version of controlfile (alter database backup controfile to trace).
Re: Review Cold backup script [message #202113 is a reply to message #202103] Wed, 08 November 2006 04:12 Go to previous messageGo to next message
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
Re: Review Cold backup script [message #202116 is a reply to message #202113] Wed, 08 November 2006 04:18 Go to previous message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
>> If any thing wrong please inform me.
Unless you test this backup (by restoring), no one can find whether there is any problem.Smile
Previous Topic: Restore and recover of corrupted datafiles
Next Topic: Backup using RMAN failed
Goto Forum:
  


Current Time: Thu May 02 20:47:01 CDT 2024