Friday, October 08, 2010

RMAN Consistent Backup



A Consistent backup of a Database is made by starting the Database in MOUNT mode. The backup is consistent, and does not require recovery after it is restored. 


1-2-3 steps for consistent  backup of database
(usually for non-archive databases)

Step 1

create command file for backup. The database is shutdown and started in mount mode, and then the backup is run. After backup finishes, database is open and then crosscheck the backup. Any expired or obsolete backups are deleted.

rman_backup_testdb.cmd
host 'echo Starting rman_backup_testdb.cmd on db2, `date`.';
shutdown immediate;
startup mount;
run {
    allocate channel ch_d1 type disk format '/orabkup1/oracle/BACKUP/testdb/RMAN_%d.%t.%s.%U'
MAXPIECESIZE 2048m;
        set command id to 'DB_FULL';
        backup as compressed backupset
          full
          filesperset = 1024
          diskratio = 0
          tag = 'Full'
          database include current controlfile ;
}
   alter database open;
   crosscheck backupset;
   delete force noprompt expired backup;
   delete force noprompt obsolete ;
   list backup;
host 'echo Ending rman_backup_testdb.cmd on db2, `date`.';

step 2

create the script to execute the command file created in step 1. In this step database environment is set and rman command is executed

rman_backup_testdb.sh
. ~/.profile
ORACLE_SID=testdb;ORAENV_ASK=NO;. oraenv;ORAENV_ASK=YES
cd /ora01/oracle/admin/BACKUP/testdb
rman target / nocatalog cmdfile=rman_backup_testdb.cmd
status=$?
exit $status


step 3

create this script to actually run the backup, now. This step creates the logfile of rman backup of database.

bkup.sh
echo "rman_backup_testdb_special.sh > rman_backup_testdb_special.log 2>&1" | at now

Hope this help. Regards Rupam