Monday, December 14, 2009

Sample RMAN backup in noarchivelog mode

RMAN Backup Scripts

RMAN> run {
2> backup database format '/u01/stage/db_%U';
3> backup current controlfile format '/u01/stage/cntrl_%U';
4> backup spfile format '/u01/stage/spfile_%U';
4> sql "alter database backup controlfile to ''/u01/stage/control.ctl'' reuse";
4> sql "alter database backup controlfile to trace as ''/u01/stage/control.trc'' reuse";
4> sql "create pfile=''/u01/stage/pfile.ora'' from spfile";
5> }


RMAN Outputs

[oracle@vmxdb01 TEST]$ ls -l /u01/stage/
total 317908
-rw-r----- 1 oracle oinstall 7110656 Dec 14 17:47 cntrl_07l0tcpr_1_1
-rw-r----- 1 oracle oinstall 7061504 Dec 14 19:21 control.ctl
-rw-r--r-- 1 oracle oinstall 6015 Dec 14 19:22 control.trc
-rw-r----- 1 oracle oinstall 303767552 Dec 14 17:47 db_05l0tcp9_1_1
-rw-r----- 1 oracle oinstall 7143424 Dec 14 17:47 db_06l0tcpo_1_1
-rw-r--r-- 1 oracle oinstall 981 Dec 14 19:22 pfile.ora
-rw-r----- 1 oracle oinstall 98304 Dec 14 17:47 spfile_08l0tcps_1_1


RMAN Restoration Using Above Backup

[oracle@vmxdb01 stage]$ rman target /

Recovery Manager: Release 10.2.0.4.0 - Production on Mon Dec 14 19:34:26 2009

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

connected to target database (not started)

RMAN> startup nomount

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db_1/dbs/initTEST.ora'

starting Oracle instance without parameter file for retrival of spfile
Oracle instance started

Total System Global Area 159383552 bytes

Fixed Size 1266344 bytes
Variable Size 54529368 bytes
Database Buffers 100663296 bytes
Redo Buffers 2924544 bytes

RMAN> restore spfile from '/u01/stage/spfile_08l0tcps_1_1';

Starting restore at 14-DEC-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=36 devtype=DISK

channel ORA_DISK_1: autobackup found: /u01/stage/spfile_08l0tcps_1_1
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 14-DEC-09

RMAN> startup force nomount

Oracle instance started

Total System Global Area 608174080 bytes

Fixed Size 1268920 bytes
Variable Size 167773000 bytes
Database Buffers 436207616 bytes
Redo Buffers 2924544 bytes

RMAN> restore controlfile from '/u01/stage/cntrl_07l0tcpr_1_1';

Starting restore at 14-DEC-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
output filename=/u01/app/oracle/oradata/TEST/control01.ctl
output filename=/u01/app/oracle/oradata/TEST/control02.ctl
output filename=/u01/app/oracle/oradata/TEST/control03.ctl
Finished restore at 14-DEC-09

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> restore database check readonly;

Starting restore at 14-DEC-09
Starting implicit crosscheck backup at 14-DEC-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
Crosschecked 6 objects
Finished implicit crosscheck backup at 14-DEC-09

Starting implicit crosscheck copy at 14-DEC-09
using channel ORA_DISK_1
Finished implicit crosscheck copy at 14-DEC-09

searching for all files in the recovery area
cataloging files...
no files cataloged

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/TEST/system01.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/TEST/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/TEST/sysaux01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/TEST/users01.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/TEST/test01.dbf
channel ORA_DISK_1: reading from backup piece /u01/stage/db_05l0tcp9_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/stage/db_05l0tcp9_1_1 tag=TAG20091214T174721
channel ORA_DISK_1: restore complete, elapsed time: 00:00:26
Finished restore at 14-DEC-09

RMAN> alter database open resetlogs;

database opened