Friday, September 11, 2015

Cold backup

How to take a cold backup


$> cd /oracle/backup/SID

$> mkdir -p /oracle/backup/SID/log

create the pfile from the current spfile.

$> sqlplus / as sysdba

SQL> alter system checkpoint;
SQL> shutdown immediate;
SQL> startup mount;
SQL> create pfile='/oracle/backup/SID/pfile`date +%d%m%Y`.ora' from spfile;

Create the backup script

Database needs to be put in mount state.

While backing up the database backup the current control file as well to disk seperately.

$> vi RMAN_cold_backup.sh

 export ORACLE_HOME=/oracle/product/11.2.0
 export ORACLE_SID=SID
 export PATH=$ORACLE_HOME/bin:$PATH
 export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
 rman target / log=/oracle/backup/SID/log/SID`date +%d%m%Y`.log <  RUN {
 ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT ‘/oracle/backup/SID/SID_%U’;
 ALLOCATE CHANNEL disk2 DEVICE TYPE DISK FORMAT ‘/oracle/backup/SID/SID_%U’;
 ALLOCATE CHANNEL disk3 DEVICE TYPE DISK FORMAT ‘/oracle/backup/SID/SID_%U’;
 BACKUP AS COMPRESSED BACKUPSET DATABASE;
 BACKUP CURRENT CONTROLFILE FORMAT ‘/oracle/backup/SID/cntrl_%s_%p_%t’;
 RELEASE CHANNEL disk1;
 RELEASE CHANNEL disk2;
 RELEASE CHANNEL disk3;
 }


Change the permission of the file RMAN_cold_backup.sh to have execute permissions.

navigate to the directory which have the script

cd /oracle/backup/SID

./RMAN_cold_backup.sh

once the script completes sucessfully, you can open the database.

$> sqlplus / as sysdba

SQL> alter database open;

Database Opened.

SQL> exit


No comments:

Post a Comment