Oracle – RMAN offline backup


[adsense id=”0514458240″ width=”468″ height=”60″]

How can we use RMAN to take an offline backup of the database. Easy we need to first shutdown the database, mount it, then issue the backup and finally open the database. This can be easily scripted but we will show each command individually run.

The first step is to shutdown the database. This is the only way of taking an offline backup in Oracle i.e. shutting down the server. In this case here we are in the RMAN shell when we issue the command:

RMAN> shutdown immediate

database closed
database dismounted
Oracle instance shut down

Now we need to mount the database. Again it is possible to issue the “startup mount” command directly from the RMAN prompt.

RMAN> startup mount

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area     134217728 bytes

Fixed Size                     1257596 bytes
Variable Size                 79695748 bytes
Database Buffers              50331648 bytes
Redo Buffers                   2932736 bytes

Now we issue the backup command in RMAN.

RMAN> backup database;
Starting backup at 29-OCT-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=36 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00004 name=/usr/lib/oracle/xe/oradata/XE/users.dbf
input datafile fno=00001 name=/usr/lib/oracle/xe/oradata/XE/system.dbf
input datafile fno=00003 name=/usr/lib/oracle/xe/oradata/XE/sysaux.dbf
input datafile fno=00002 name=/usr/lib/oracle/xe/oradata/XE/undo.dbf
channel ORA_DISK_1: starting piece 1 at 29-OCT-12
channel ORA_DISK_1: finished piece 1 at 29-OCT-12
piece handle=/usr/lib/oracle/xe/app/oracle/flash_recovery_area/XE/backupset/2012_10_29/o1_mf_nnndf_TAG20121029T160147_88x6lvbb_.bkp tag=TAG20121029T160147 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:25
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 29-OCT-12
channel ORA_DISK_1: finished piece 1 at 29-OCT-12
piece handle=/usr/lib/oracle/xe/app/oracle/flash_recovery_area/XE/backupset/2012_10_29/o1_mf_ncsnf_TAG20121029T160147_88x6ok6x_.bkp tag=TAG20121029T160147 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 29-OCT-12

Now that the backup has completed we now need to open the database so that it is accessible by end users. RMAN allows SQL statements to be executed from the command prompt by issuing “SQL” following by the command to be executed.

RMAN> sql 'alter database open';

sql statement: alter database open