Please see my other blog for Oracle EBusiness Suite Posts - EBMentors

Search This Blog

Note: All the posts are based on practical approach avoiding lengthy theory. All have been tested on some development servers. Please don’t test any post on production servers until you are sure.

Tuesday, December 07, 2010

RMAN Backup Intro - Example (10gR2)

RMAN creates compressed backups of the physical database; if you prefer, rman zips the database, entirely or not. For taking RMAN backup, your database should be in archivelog mode.

As I've many databases on one server, I set the ORACLE_SID for my target database. 
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

C:\Documents and Settings\inam>set ORACLE_SID=ASMDB
C:\Documents and Settings\inam>rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Tue Dec 7 13:34:52 2010
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to target database: ASMDB (DBID=477607595)
Simple Full DB Backup
RMAN> run {
2> allocate channel CHNL1 type disk;
3> backup database format 'D:\Home_Backup\ASMRMAN\%d_%u_%s';
4> release channel CHNL1;
5> }

using target database control file instead of recovery catalog
allocated channel: CHNL1
channel CHNL1: sid=35 devtype=DISK

Starting backup at 07-DEC-10
channel CHNL1: starting full datafile backupset
channel CHNL1: specifying datafile(s) in backupset
input datafile fno=00001 name=+DB_DATA/asmdb/datafile/system.259.733408841
input datafile fno=00003 name=+DB_DATA/asmdb/datafile/sysaux.261.733408851
input datafile fno=00004 name=+DB_DATA/asmdb/datafile/myts_on_asm.263.733412067
input datafile fno=00006 name=+DB_DATA/asmdb/datafile/ggs_data.267.734093627
input datafile fno=00007 name=+DB_DATA/asmdb/datafile/users.dbf
input datafile fno=00008 name=+DB_DATA/asmdb/datafile/example.dbf
input datafile fno=00002 name=+DB_DATA/asmdb/datafile/undotbs1.260.733408851
input datafile fno=00005 name=+DB_DATA/asmdb/datafile/xdb.264.733412967
channel CHNL1: starting piece 1 at 07-DEC-10
channel CHNL1: finished piece 1 at 07-DEC-10
piece handle=D:\HOME_BACKUP\ASMRMAN\ASMDB_01LUVB28_1 tag=TAG20101207T133816 comment=NONE
channel CHNL1: backup set complete, elapsed time: 00:00:35
channel CHNL1: starting full datafile backupset
channel CHNL1: specifying datafile(s) in backupset
including current control file in backupset
channel CHNL1: starting piece 1 at 07-DEC-10
channel CHNL1: finished piece 1 at 07-DEC-10
piece handle=D:\HOME_BACKUP\ASMRMAN\ASMDB_02LUVB3B_2 tag=TAG20101207T133816 comment=NONE
channel CHNL1: backup set complete, elapsed time: 00:00:03
Finished backup at 07-DEC-10

released channel: CHNL1

Archive Log Backup
run {
     allocate channel CHNL1 type disk;
     backup archivelog   from logseq 28 format 'D:\HOME_BACKUP\ASMRMAN\arch_%d_%u_%s'        delete input;
    }


-- from logseq 12 until logseq 15 thread 1
allocated channel: CHNL1
channel CHNL1: sid=35 devtype=DISK

Starting backup at 07-DEC-10
current log archived
channel CHNL1: starting archive log backupset
channel CHNL1: specifying archive log(s) in backup set
input archive log thread=1 sequence=28 recid=10 stamp=736607184
input archive log thread=1 sequence=29 recid=11 stamp=736608475
input archive log thread=1 sequence=30 recid=12 stamp=736725653
input archive log thread=1 sequence=31 recid=13 stamp=736815660
input archive log thread=1 sequence=32 recid=14 stamp=736959069
input archive log thread=1 sequence=33 recid=15 stamp=737075170
input archive log thread=1 sequence=34 recid=16 stamp=737127824
input archive log thread=1 sequence=35 recid=17 stamp=737128020
input archive log thread=1 sequence=36 recid=18 stamp=737128424
input archive log thread=1 sequence=37 recid=19 stamp=737128507
input archive log thread=1 sequence=38 recid=20 stamp=737128534
input archive log thread=1 sequence=39 recid=21 stamp=737128582
channel CHNL1: starting piece 1 at 07-DEC-10
channel CHNL1: finished piece 1 at 07-DEC-10
piece handle=D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\06LUVC47_1_1 tag=TAG20101207T135622 comment=NONE
channel CHNL1: backup set complete, elapsed time: 00:00:17
channel CHNL1: deleting archive log(s)
archive log filename=+DB_ARCHIVELOG/asmdb/archivelog/asmdb_00028_0733408811.001.arc recid=10 stamp=736607184
archive log filename=+DB_ARCHIVELOG/asmdb/archivelog/asmdb_00029_0733408811.001.arc recid=11 stamp=736608475
archive log filename=+DB_ARCHIVELOG/asmdb/archivelog/asmdb_00030_0733408811.001.arc recid=12 stamp=736725653
archive log filename=+DB_ARCHIVELOG/asmdb/archivelog/asmdb_00031_0733408811.001.arc recid=13 stamp=736815660
archive log filename=+DB_ARCHIVELOG/asmdb/archivelog/asmdb_00032_0733408811.001.arc recid=14 stamp=736959069
archive log filename=+DB_ARCHIVELOG/asmdb/archivelog/asmdb_00033_0733408811.001.arc recid=15 stamp=737075170
archive log filename=+DB_ARCHIVELOG/asmdb/archivelog/asmdb_00034_0733408811.001.arc recid=16 stamp=737127824
archive log filename=+DB_ARCHIVELOG/asmdb/archivelog/asmdb_00035_0733408811.001.arc recid=17 stamp=737128020
archive log filename=+DB_ARCHIVELOG/asmdb/archivelog/asmdb_00036_0733408811.001.arc recid=18 stamp=737128424
archive log filename=+DB_ARCHIVELOG/asmdb/archivelog/asmdb_00037_0733408811.001.arc recid=19 stamp=737128507
archive log filename=+DB_ARCHIVELOG/asmdb/archivelog/asmdb_00038_0733408811.001.arc recid=20 stamp=737128534
archive log filename=+DB_ARCHIVELOG/asmdb/archivelog/asmdb_00039_0733408811.001.arc recid=21 stamp=737128582
Finished backup at 07-DEC-10
released channel: CHNL1

RMAN> list backupset ; -- list backupset  7; shows all the backupsets you have

RMAN> validate backupset 6; --Validates and shows the error message if there is problem
RMAN> delete backupset 2;
using channel ORA_DISK_1
List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
2       2       1   1   AVAILABLE   DISK        D:\HOME_BACKUP\ASMRMAN\ASMDB_02LUVB3B_2

Do you really want to delete the above objects (enter YES or NO)? y
deleted backup piece
backup piece handle=D:\HOME_BACKUP\ASMRMAN\ASMDB_02LUVB3B_2 recid=2 stamp=737127533
Deleted 1 objects
- Delete backupset will delete if backupset is available with its files
- It will give following error if backupset is available but associated files deleted from OS
 RMAN> delete backupset 7;

using channel ORA_DISK_1

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
7       7       1   1   AVAILABLE   DISK        D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\07LUVC7L_1_1

Do you really want to delete the above objects (enter YES or NO)? y

RMAN-06207: WARNING: 1 objects could not be deleted for DISK channel(s) due
RMAN-06208:          to mismatched status.  Use CROSSCHECK command to fix status
RMAN-06210: List of Mismatched objects
RMAN-06211: ==========================
RMAN-06212:   Object Type   Filename/Handle
RMAN-06213: --------------- ---------------------------------------------------
RMAN-06214: Backup Piece    D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\07LUVC7L_1_1
- It wil give following error if backupset is not available
RMAN> delete backupset 10;

using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of delete command at 12/07/2010 14:19:58
RMAN-20215: backup set not found
RMAN-06159: error while looking up backup set

No comments: