In Oracle : Oracle RMAN full (level 0) backup - online backup

Oracle Applications EBS 11i, R12      Oracle Database      Data Warehouse & BI      Oracle Middleware      PL/SQL      Linux ...

Oracle DBA

Real Application Cluster (RAC) Maintenance tasks Backup and Recovery Database Architecture Replication Oracle Performance Tuning Oracle DBA - Other articles Oracle scripts/ Selects for DBA Oracle Errors (ORA-nnnnn)

The last articles in the site (HOT)

The most visited articles in the site

In-Oracle.com  -> Oracle DBA -> Oracle Database Backup and Recovery

-> RMAN full (level 0) backup - online backup

 

 RMAN full (level 0) backup - online backup

 

Here are the main topics for this article:

Creating the script for the On-line backup using RMAN

 

Here is the content of /home/oracle/Desktop/Backup_rman/scripts/hot_database_backup_disk.sh :

 

#/usr/bin/ksh

export ORACLE_HOME=/DB1
export ORACLE_SID=db1
RMAN_LOG_FILE=/home/oracle/Desktop/Backup_rman/log/hot_database_backup.`date +%y%m%d%H%M`.out

# -----------------------------------------------------------------
# Initialize the log file.
# -----------------------------------------------------------------

echo>> $RMAN_LOG_FILE
chmod 666 $RMAN_LOG_FILE

echo Script $0>> $RMAN_LOG_FILE
echo ==== started on `date` ====>> $RMAN_LOG_FILE
echo>> $RMAN_LOG_FILE

ORACLE_USER=oracle
TARGET_CONNECT_STR=sys/s

RMAN=$ORACLE_HOME/bin/rman
BACKUP_TYPE="INCREMENTAL LEVEL 0"

# ---------------------------------------------------------------------------
# Print out the value of the variables set by this script.
# ---------------------------------------------------------------------------
echo>> $RMAN_LOG_FILE
echo "RMAN: $RMAN">> $RMAN_LOG_FILE
echo "ORACLE_SID: $ORACLE_SID">> $RMAN_LOG_FILE
echo "ORACLE_USER: $ORACLE_USER">> $RMAN_LOG_FILE
echo "ORACLE_HOME: $ORACLE_HOME">> $RMAN_LOG_FILE
echo "BACKUP_TYPE: $BACKUP_TYPE">> $RMAN_LOG_FILE
# ---------------------------------------------------------------------------


echo >> $RMAN_LOG_FILE
CMD_STR=""

$RMAN target $TARGET_CONNECT_STR catalog rman/r@dbr << EOF
RUN {
ALLOCATE CHANNEL ch00 TYPE disk ;
ALLOCATE CHANNEL ch01 TYPE disk ;
ALLOCATE CHANNEL ch02 TYPE disk ;
ALLOCATE CHANNEL ch03 TYPE disk ;
BACKUP
$BACKUP_TYPE
SKIP INACCESSIBLE
TAG hot_db_bk_level0
FILESPERSET 5
# recommended format
FORMAT '/home/oracle/Desktop/Backup_rman/backup/bk_%s_%p_%t'
DATABASE;
sql 'alter system archive log current';
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
RELEASE CHANNEL ch02;
RELEASE CHANNEL ch03;
# backup all archive logs
ALLOCATE CHANNEL ch00 TYPE disk;
ALLOCATE CHANNEL ch01 TYPE disk;

BACKUP
SKIP INACCESSIBLE
filesperset 20
FORMAT '/home/oracle/Desktop/Backup_rman/backup/al_%s_%p_%t'
ARCHIVELOG ALL DELETE INPUT;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
ALLOCATE CHANNEL ch00 TYPE disk;
BACKUP
# recommended format
FORMAT '/home/oracle/Desktop/Backup_rman/backup/cntrl_%s_%p_%t'
CURRENT CONTROLFILE;
RELEASE CHANNEL ch00;
}
EOF

NOTE: The database must be in archivelog mode. 

 

 

Running the shell script to start the backup

 

 

RMAN full (level 0) backup - online backup

 

Here are the messages which appears during the online backup:

 

[oracle@PROD scripts]$ ./hot_database_backup_disk.sh

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Mar 25 22:38:21 2008

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: DB1 (DBID=1244100437)
connected to recovery catalog database

RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19> 20> 21> 22> 23> 24> 25> 26> 27> 28> 29> 30> 31> 32> 33> 34> 35> 36> 37>
allocated channel: ch00
channel ch00: sid=159 devtype=DISK

allocated channel: ch01
channel ch01: sid=152 devtype=DISK

allocated channel: ch02
channel ch02: sid=144 devtype=DISK

allocated channel: ch03
channel ch03: sid=148 devtype=DISK

Starting backup at 25-MAR-08
channel ch00: starting incremental level 0 datafile backupset
channel ch00: specifying datafile(s) in backupset
input datafile fno=00001 name=/DB1/oradata/db1/system01.dbf
channel ch00: starting piece 1 at 25-MAR-08
channel ch01: starting incremental level 0 datafile backupset
channel ch01: specifying datafile(s) in backupset
input datafile fno=00003 name=/DB1/oradata/db1/sysaux01.dbf
input datafile fno=00004 name=/DB1/oradata/db1/users01.dbf
channel ch01: starting piece 1 at 25-MAR-08
channel ch02: starting incremental level 0 datafile backupset
channel ch02: specifying datafile(s) in backupset
input datafile fno=00005 name=/DB1/oradata/db1/example01.dbf
input datafile fno=00002 name=/DB1/oradata/db1/undotbs01.dbf
channel ch02: starting piece 1 at 25-MAR-08
channel ch03: starting incremental level 0 datafile backupset
channel ch03: specifying datafile(s) in backupset
including current control file in backupset
channel ch03: starting piece 1 at 25-MAR-08
channel ch03: finished piece 1 at 25-MAR-08
piece handle=/home/oracle/Desktop/Backup_rman/backup/bk_23_1_650327905 tag=HOT_DB_BK_LEVEL0 comment=NONE
channel ch03: backup set complete, elapsed time: 00:00:08
channel ch03: starting incremental level 0 datafile backupset
channel ch03: specifying datafile(s) in backupset
channel ch02: finished piece 1 at 25-MAR-08
piece handle=/home/oracle/Desktop/Backup_rman/backup/bk_22_1_650327905 tag=HOT_DB_BK_LEVEL0 comment=NONE
channel ch02: backup set complete, elapsed time: 00:00:08
including current SPFILE in backupset
channel ch03: starting piece 1 at 25-MAR-08
channel ch00: finished piece 1 at 25-MAR-08
piece handle=/home/oracle/Desktop/Backup_rman/backup/bk_20_1_650327905 tag=HOT_DB_BK_LEVEL0 comment=NONE
channel ch00: backup set complete, elapsed time: 00:00:15
channel ch01: finished piece 1 at 25-MAR-08
piece handle=/home/oracle/Desktop/Backup_rman/backup/bk_21_1_650327905 tag=HOT_DB_BK_LEVEL0 comment=NONE
channel ch01: backup set complete, elapsed time: 00:00:15
channel ch03: finished piece 1 at 25-MAR-08
piece handle=/home/oracle/Desktop/Backup_rman/backup/bk_24_1_650327913 tag=HOT_DB_BK_LEVEL0 comment=NONE
channel ch03: backup set complete, elapsed time: 00:00:07
Finished backup at 25-MAR-08

sql statement: alter system archive log current

released channel: ch00

released channel: ch01

released channel: ch02

released channel: ch03

allocated channel: ch00
channel ch00: sid=159 devtype=DISK

allocated channel: ch01
channel ch01: sid=152 devtype=DISK

Starting backup at 25-MAR-08
current log archived
channel ch00: starting archive log backupset
channel ch00: specifying archive log(s) in backup set
input archive log thread=1 sequence=1 recid=5 stamp=650327923
channel ch00: starting piece 1 at 25-MAR-08
channel ch01: starting archive log backupset
channel ch01: specifying archive log(s) in backup set
input archive log thread=1 sequence=2 recid=6 stamp=650327924
channel ch01: starting piece 1 at 25-MAR-08
channel ch00: finished piece 1 at 25-MAR-08
piece handle=/home/oracle/Desktop/Backup_rman/backup/al_25_1_650327925 tag=TAG20080325T223845 comment=NONE
channel ch00: backup set complete, elapsed time: 00:00:02
channel ch00: deleting archive log(s)
archive log filename=/DB1/flash_recovery_area/DB1/archivelog/2008_03_25/o1_mf_1_1_3ymb92xz_.arc recid=5 stamp=650327923
channel ch01: finished piece 1 at 25-MAR-08
piece handle=/home/oracle/Desktop/Backup_rman/backup/al_26_1_650327925 tag=TAG20080325T223845 comment=NONE
channel ch01: backup set complete, elapsed time: 00:00:03
channel ch01: deleting archive log(s)
archive log filename=/DB1/flash_recovery_area/DB1/archivelog/2008_03_25/o1_mf_1_2_3ymb94lz_.arc recid=6 stamp=650327924
Finished backup at 25-MAR-08

released channel: ch00

released channel: ch01

allocated channel: ch00
channel ch00: sid=159 devtype=DISK

Starting backup at 25-MAR-08
channel ch00: starting full datafile backupset
channel ch00: specifying datafile(s) in backupset
including current control file in backupset
channel ch00: starting piece 1 at 25-MAR-08
channel ch00: finished piece 1 at 25-MAR-08
piece handle=/home/oracle/Desktop/Backup_rman/backup/cntrl_27_1_650327930 tag=TAG20080325T223850 comment=NONE
channel ch00: backup set complete, elapsed time: 00:00:01
Finished backup at 25-MAR-08

released channel: ch00

RMAN>

Recovery Manager complete.
[oracle@PROD scripts]$

 

 

Delete the database files 

 

To test the backup, I stop the database (even if is not mandatory :) ), I delete all the database files (control files, log file, data files) and after that I restore the files using RMAN. 

 

If I want to startup the database I receive a message of error because the control files are not present:

 

RMAN full (level 0) backup - online backup

 

 

Restore & Recover the database using RMAN

 

To restore the database (physically the files are restored, but the files = the database)  we have to connect to the target database and recovery catalog, to startup the database in nomount state, restore the control file and alter the database to be in mount state. 

 

RMAN full (level 0) backup - online backup

 

 

In the mount state we have to run:

 

RMAN> RESTORE DATABASE;

 

(We can run RMAN> RESTORE DATABASE VALIDATE, as well to check that all is ok and database could be opened.)

 

RMAN> RECOVER DATABASE;

 

And after that we can open the database (in RESETLOG mode)

 

RMAN> ALTER DATABASE OPEN RESETLOGS; 

 

The new database will be registered with the RMAN catalog automatically:

 

RMAN full (level 0) backup - online backup

 

 

 

In-Oracle.com  -> Oracle DBA -> Oracle Database Backup and Recovery

-> RMAN full (level 0) backup - online backup

Oracle Applications EBS 11i, R12      Oracle Database      Data Warehouse & BI      Oracle Middleware      PL/SQL      Linux ...

 

     Copyright (c) 2011-2015  www.in-oracle.com  |  Disclaimer: The views expressed on this web site are my own and do not reflect the views of Oracle Corporation. You may use the information from this site only at your risk.