Oracle Database Cold Backup Script

Execute this bash script, it will do the rest of your Database Cold Backup.

ColdBackup.sh


#!/bin/sh
/oracle/app/product/10.2.0/db_1/bin/sqlplus /nolog <<EOF
conn /as sysdba
@/home/oracle/ColdBackupScript.sql
EOF

This will generate the Database File List ColdBackupFileList.sql and execute it as well.

ColdBackupScript.sql


Rem Set SQL*Plus variables to manipulate output
set feedback off heading off verify off
set pagesize 0 linesize 200
Rem Set SQL*Plus user variables used in script
Rem Linux User variables
define dir = '/backup/cold_backup'
define fil = '/backup/cold_backup/ColdBackupFileList.sql'
prompt *** Spooling to &fil
spool &fil
select 'host cp '|| name ||' &dir' from v$datafile order by 1;
select 'host cp '|| member ||' &dir' from v$logfile order by 1;
select 'host cp '|| name ||' &dir' from v$controlfile order by 1;
select 'host cp '|| name ||' &dir' from v$tempfile order by 1;
select 'host cp '||value ||' &dir' from v$parameter where name='spfile';
spool off;
Rem Shutdown the database cleanly
shutdown immediate;
Rem Run the copy file commands
@&fil
Rem Start the database again
startup;


This is the generated final script for taking Cold Backup.
ColdBackupFileList.sql


host cp /database/SIBL/ababil_data_ts01.dbf /backup/cold_backup/20_06_2010                                                                                                                              
host cp /database/SIBL/ababil_image_ts01.dbf /backup/cold_backup/20_06_2010                                                                                                                             
host cp /database/SIBL/ababil_index_ts01.dbf /backup/cold_backup/20_06_2010                                                                                                                             
host cp /database/SIBL/rman_ts01.dbf /backup/cold_backup/20_06_2010                                                                                                                                     
host cp /database/SIBL/sysaux01.dbf /backup/cold_backup/20_06_2010                                                                                                                                      
host cp /database/SIBL/system01.dbf /backup/cold_backup/20_06_2010                                                                                                                                      
host cp /database/SIBL/undotbs01.dbf /backup/cold_backup/20_06_2010                                                                                                                                     
host cp /database/SIBL/redo01.log /backup/cold_backup/20_06_2010                                                                                                                                        
host cp /database/SIBL/redo02.log /backup/cold_backup/20_06_2010                                                                                                                                        
host cp /database/SIBL/redo03.log /backup/cold_backup/20_06_2010                                                                                                                                        
host cp /database/SIBL/control01.ctl /backup/cold_backup/20_06_2010                                                                                                                                     
host cp /database/SIBL/control02.ctl /backup/cold_backup/20_06_2010                                                                                                                                     
host cp /database/SIBL/control03.ctl /backup/cold_backup/20_06_2010                                                                                                                                     
host cp /database/SIBL/ababil_temp_ts01.dbf /backup/cold_backup/20_06_2010                                                                                                                              
host cp /oracle/app/product/10.2.0/db_1/dbs/spfileSIBL.ora /backup/cold_backup/20_06_2010                                                                                                               


Thanks
A Rahim Khan

Advertisements
    • sredhar
    • July 22nd, 2012

    Reblogged this on Oracle DBA Readers Site.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: