Backup and recovery with RMAN

 

 

Just a few examples or use of RMAN utility. Be aware that RMAN syntax
is version dependent, the examples below work for Oracle 10g and 11g.

Database ad-hoc backup

In this example we are backing up a database without RMAN repository.

First we check the current settings the we launch a backup to disk. Your

database must be in archivelog mode to use the following example.

 

oracle@host> rman target /

 

RMAN> show all;

 

RMAN> run {

allocate channel ch1 type disk;

BACKUP CURRENT CONTROLFILE;

release channel ch1;

}

 

 

RMAN> run {

allocate channel ch1 type disk;

allocate channel ch2 type disk;

allocate channel ch3 type disk;

allocate channel ch4 type disk;

backup database;

release channel ch1;

release channel ch2;

release channel ch3;

release channel ch4;

}

 

 

Restore a database from disk

1) We make sure the database can start in nomount:

 

oracle@host> sqlplus / as sysdba

SQL> startup nomount

ORACLE instance started.

SQL> exit;

 

2) Then we recover control file first then the database with RMAN:

 

oracle@host> rman target /

 

RMAN> run {

restore controlfile from autobackup;

}

 

RMAN> run {

allocate channel ch1 type disk;

allocate channel ch2 type disk;

allocate channel ch3 type disk;

allocate channel ch4 type disk;

restore database;

recover database;

release channel ch1;

release channel ch2;

release channel ch3;

release channel ch4;

}

 

Restore only the recover until time

1) Restore the database with RMAN

 

oracle@host> rman target /

 

RMAN> run {

restore controlfile from autobackup;

}

 

RMAN> run {

allocate channel ch1 type disk;

allocate channel ch2 type disk;

restore database;

release channel ch1;

release channel ch2;

}

 

 

2) Roll forward the database until specified time

 

SQL> recover database using backup controlfile until time '2012-02-20 10:30:00';

 

3) Check SCN numbers in file headers and open the database

 

SQL>  set pages 200

SQL>  alter session set NLS_DATE_FORMAT = 'YYYY MM DD HH24:MI:SS';

SQL>  select to_char(CHECKPOINT_CHANGE#) from  v$datafile_header;

SQL>  alter database open resetlogs;

 

Rounded Rectangle: Home Page