RMAN Mini Guide

One question: whats the most important task
for a DBA Administrator? three words, BACKUP,BACKUP,BACKUP.

Lets put hands of the most important task of a DBA …

Export/import? NO. this isnt the backup.

So lets take a look on Recovery Manager, normal called RMAN.
If you dont know what is that, how you do the backup?.

ok lets go, first of all for a good knowledge about rman
please refer to oficial guides and manuals.

ORACLE Database backup and recovery documentation: http://docs.oracle.com/database/121/RCMRF/toc.htm

1- login and Parameters

By default oracle store catalog on datbase controlfile
when un login normal and no specify catalog by default is nocatalog mode:

rman target /

or Oracle Net authentication:

rman TARGET SYS/*****@database_sid

you can login with catalog, maybe you store catalog in other database
(in other post i will describe how create a catalog database is easy):

rman TARGET / CATALOG rman/cat@catdb

or

# Oracle Net authentication
rman TARGET SYS/oracle@database_sid CATALOG rman/cat@catdb

somer basic Parameters, for view parameters: show all

RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

Ensure that RMAN retains all backups needed to recover the database to any point in time in the last 7 days, is example change as need.
RMAN> CONFIGURE BACKUP OPTIMIZATION ON;
backup flash recovery area, no take backups from archivelogs alredy been backed up, no take backup of read only tablespace
if there is a valid copy on catalog of this tablespace
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
where go backup
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
backup control file with each backup.
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/mnt/backup/DB11GPROD/RMAN_DB11GPROD/ctl_DB11GPRO1_%F’;
format and path for controlfile backup in disk.
RMAN> CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT ‘/mnt/backup/DB11GPROD/RMAN_DB11GPROD/%U’;
format of backupset:
RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘+FLASH/DB11GPROD/SPFILE/snapcf_DB11GPRO1.f’;
each change on controlfile will produce a copy of this file in plain text for recreate.

2- Managing RMAN: some usefull commands

– List information:
list backup of controlfile;
list backup; (detallado)
LIST BACKUP OF DATABASE;
list backupset (by backup|by file) (sumary|verbose);
list backupset by backup; (sumary|verbose);
list backupset by file; (sumary|verbose);
list backup summary;
list backup of database;
list archivelog all;
list expired backup;

– Report of needs:

report need backup;
report obsolete;
report expired;
report schema;

– Manage backups:

crosscheck backup;
delete expired backup;
crosscheck archivelog all;
DELETE EXPIRED ARCHIVELOG ALL;
DELETE FORCE EXPIRED ARCHIVELOG ALL;
DELETE OBSOLETE;
blockrecover corruption list;

delete archivelog until sequence=<num>
delete archivelog all;
delete archivelog until time ‘SYSDATE-10’;
delete archivelog from time ‘SYSDATE-10’
delete archivelog from time ‘SYSDATE-10’ until time ‘SYSDATE-2’;
delete archivelog from sequence 2807;
delete archivelog until sequence 1500;
delete archivelog from sequence 1000 until sequence 1500;
delete noprompt archivelog until time ‘SYSDATE-10’; (for do not yes-no question.)
list incarnation of database;
delete backupset 2481;
advise failure all;
repair failure preview;
backup validate database in RMAN;
blockrecover corruption list;

– Catalog archives and backupsets

CATALOG START WITH ‘/bbdd/PEGASO/PRUEBA/backup/nuevo’;
CATALOG START WITH ‘/mnt/backup/ERPPRO/RMAN_ERPPRO/archivados’;
CATALOG BACKUPPIECE ‘/u04/restore_database_backup/20100701_DAPRO01_DBID423913798_s233_p1_dbf’;

3- Backup

tipical full backup with archives and control file.

run
{
allocate channel c1 type disk format ‘/oracle/backup/rman_db_%T_%U.rman’;
backup as compressed backupset full database include current controlfile;
release channel c1;
allocate channel c1 type disk format ‘/oracle/backup/rman_arc_%T_%U.rman’;
sql “alter system archive log current”;
delete noprompt archivelog all backed up 2 times to device type disk;
backup as compressed backupset archivelog all;
sql “alter database backup controlfile to ”/oracle/backup/rman_control.rman” reuse”;
release channel c1;
}

4- Check and Monitoring backup
— Reporte de Todos los backups: full, incremental and archivelog backups
col STATUS format a9
col hrs format 999.99
select
SESSION_KEY, INPUT_TYPE, STATUS,
to_char(START_TIME,’mm/dd/yy hh24:mi’) start_time,
to_char(END_TIME,’mm/dd/yy hh24:mi’) end_time,
elapsed_seconds/3600 hrs
from V$RMAN_BACKUP_JOB_DETAILS
order by session_key;

5- Restore

example of complet recovery:

startup nomount;
RESTORE CONTROLFILE from ‘/oracle/backup/rman_control.rman’; <– or RESTORE CONTROLFILE FROM AUTOBACKUP;
RESTORE SPFILE TO ‘+DATA/ORCL/spfileORCL.ora’ from ‘/oracle/backup/rman_db_20120807_o4ni1oa5_1_1.rman’; <–(optional)
alter database mount;
restore database;
recover database;
alter database open resetlogs;
alter system set control_files=’+DATA/logteca/controlfile/current.[NUMBER]’ scope=spfile;
shutdown immediate;
startup;

restore incomplete:
RECOVER DATABASE UNTIL CANCEL

Advertisements

Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s