oracle backup and recovery using rman

37
Oracle Backup and Recovery Using RMAN Mark Rank DBA UW-Platteville

Upload: shahid-mahmud

Post on 10-Apr-2015

3.228 views

Category:

Documents


4 download

DESCRIPTION

Oracle Backup and Recovery Using RMAN - Mark RankDBAUW-Platteville

TRANSCRIPT

Page 1: Oracle Backup and Recovery Using RMAN

Oracle Backup and Recovery Using RMAN

Mark RankDBA

UW-Platteville

Page 2: Oracle Backup and Recovery Using RMAN

Introduction• Who am I?

– DBA and Manager of Development for UW-Platteville

• Oracle experience– Worked with Oracle for about 10 years – Worked with RMAN for 2 years– Using RMAN version 9.2 in production

for backup at UW-Platteville

Page 3: Oracle Backup and Recovery Using RMAN

Outline• Background

– General Backup and Recovery– Overview of RMAN

• Backup using RMAN– Configuration– Reporting and monitoring– Executing a backup

• Recovery using RMAN• Cloning using RMAN

Page 4: Oracle Backup and Recovery Using RMAN

A little quiz before we start

• Backing up Oracle data files using OS commands while the database is open will give a valid backup?

• Archiving the redo log files is done only for record retention reasons?

• If you have a backup of the database you can always recover the database?

• A database will have uncommitted transactions after recovery?

Page 5: Oracle Backup and Recovery Using RMAN

DBA Motto

Thou shall not loose data!

Page 6: Oracle Backup and Recovery Using RMAN

Why do we backup?• Manage Risk

– How much risk can we afford to accept?• Cost of backup systems• Loss of customer confidence

– How much risk are we allowed to accept?• Political Factors• Cultural Factors• Legal Factors

Page 7: Oracle Backup and Recovery Using RMAN

Factors to Consider• Legislation or Organizational policies • Time to backup• Time to recover• Redundancy of your system• Criticality of the data• Monitoring• System availability during backup

Page 8: Oracle Backup and Recovery Using RMAN

Some Best Practices• Have a documented backup procedure• Have a multilayer backup process if you can• Have people trained with the recovery tools• Monitor the backup processes regularly• Correct issues with backup promptly• Conduct Fire Drills of your backup processes

Page 9: Oracle Backup and Recovery Using RMAN

What is RMAN?• Stands for Recovery Manager• Oracle’s recommended way of doing

physical backups• Supports both online (hot) and offline

(cold) backups• Does backup at the block level

resulting in a “fine grain” backup

Page 10: Oracle Backup and Recovery Using RMAN

RMAN Repository• A database used by RMAN to store

configuration and record backup information

• Optional on 9i or greater• Still need to come up with a backup

method for the repository• Not going to cover RMAN with the

repository in this presentation

Page 11: Oracle Backup and Recovery Using RMAN

RMAN without Repository

• With 9i or greater, can use the control file to store the RMAN configuration and backup data

• Will cause the control file to get larger

• May want to set the CONTROL_FILE_RECORD_KEEP_TIME

Page 12: Oracle Backup and Recovery Using RMAN

Executing RMAN• To invoke RMAN without a

repository...

cmd> rman target=[conn_string]

Page 13: Oracle Backup and Recovery Using RMAN

Viewing Configuration• To view the configuration

RMAN> show all;

• To set parametersRMAN> configure [parameter syntax];

• See the reference manual for parameter syntax

Page 14: Oracle Backup and Recovery Using RMAN

Some key parameters• RETENSION POLICY• CONTROLFILE AUTOBACKUP• CONTROLFILE AUTOBACKUP FORMAT• CHANNEL 1 DEVICE TYPE DISK

FORMAT

Page 15: Oracle Backup and Recovery Using RMAN

A Note About DBID’s• When using RMAN without a repository,

need to inventory the DBID’s• Needed for recovery without a control

file• Create a script that inventories them

as part of your back strategy

SQL> select dbid from v$database;

Page 16: Oracle Backup and Recovery Using RMAN

Performing an Online Backup

• To backup the database without the archive logsRMAN>backup database;

• To backup the database with the archive logsRMAN> Backup database plus archivelog;

• Now for a demo…

Page 17: Oracle Backup and Recovery Using RMAN

Incremental Backup• RMAN does block level incremental

backups• Define levels of backup with level 0

being a full backup• A level 0 backup must always exist

before defining higher backups• Also an option to do cumulative

backups

Page 18: Oracle Backup and Recovery Using RMAN

Incremental Backup

Day Sun Mon Tues Wed Thur Fri SunLevel 0 2 2 1 2 2 0

Page 19: Oracle Backup and Recovery Using RMAN

Incremental Backup Syntax

• To execute an incremental backupRMAN> backup incremental level=[int] database plus archivelog;

Page 20: Oracle Backup and Recovery Using RMAN

Retention Policy• Recovery Window

– Latest possible date to recover database to

– Maintains information for a point-in-time recovery anywhere in the window

• Backup Redundancy– Maintains specified number of backups

including the most current

Page 21: Oracle Backup and Recovery Using RMAN

Reporting on the Catalog• To get a summary of the backups

RMAN>list backupset summary;

• To get the details of a backup setRMAN>list backupset [int];

• Now for a demo…

Page 22: Oracle Backup and Recovery Using RMAN

Managing the Catalog• Setting the retention policy

RMAN> configure retention policy redundancy 2;

• Reporting obsoleteRMAN> report obsolete;

• Deleting obsoleteRMAN> delete obsolete;

Page 23: Oracle Backup and Recovery Using RMAN

Recovery• Read the book “Oracle9i RMAN

Backup & Recovery” or attend one of Oracle’s classes

• Recovery using RMAN is straightforward, but it is also easy to trip yourself up

• “Practice, Practice, Practice”

Page 24: Oracle Backup and Recovery Using RMAN

Recovering a Tablespace

A Demo

Page 25: Oracle Backup and Recovery Using RMAN

Using RMAN to Clone• An easy way to clone databases• A good way to validate your backup• A good way to practice recovery

Page 26: Oracle Backup and Recovery Using RMAN

Outline of the Procedure• Establish a target database and bring

it up to NOMOUNT• Connect using RMAN to the source

database• Force a checkpoint and log switch• Duplicate the source to the target

using the DUPLICATE TARGET DATABASE command

Page 27: Oracle Backup and Recovery Using RMAN

A note about files• Unless the file structures are the same you

will need to put db_file_name_convert and log_file_name_convert commands in our INIT.ORA file

• Unless all of your archive logs are in the RMAN backup, you may have to do a manual recovery because of file name issues

Page 28: Oracle Backup and Recovery Using RMAN

A note about time• If you want your clone to a be as of a

point in time, use the SET UNTIL TIME function

• You can use the TO_DATE function to specify the date

Page 29: Oracle Backup and Recovery Using RMAN

What that looks likerun {

set until time =

“to_date(‘20051012’,’yyyymmdd’)”;

duplicate target database to LSTA

pfile = \\rhea\apps\db\lsta\initlsta.ora;

}

Page 30: Oracle Backup and Recovery Using RMAN

For more details• See Chapter 16 of “Oracle9i RMAN

Backup & Recovery”

Page 31: Oracle Backup and Recovery Using RMAN

A Word about Compatibility

• In general executable must match target database

• See Appendix B of the RMAN Reference for details.

Page 32: Oracle Backup and Recovery Using RMAN

One Parting Note• Test your backups

– Fire drill regularly– If possible use your backups as the

source for test databases

• Nothing worse than needing to recover and finding out the tape is blank

Page 33: Oracle Backup and Recovery Using RMAN

Summary• Background

– General Backup and Recovery– Overview of RMAN

• Backup using RMAN– Configuration– Reporting and monitoring– Executing a backup

• Recovery using RMAN• Cloning using RMAN

Page 34: Oracle Backup and Recovery Using RMAN

Bibliography• Where does this information come

from?– Oracle 9i RMAN Backup & Recovery– Oracle 9i New Features Overview Class– Oracle 8 Backup and Recovery

Workshop– My own experimentation

Page 35: Oracle Backup and Recovery Using RMAN

Some Resources• Oracle9i RMAN Backup & Recovery

– By Freeman and Hart – Published by Oracle Press

• Oracle Manuals– Recovery Manager Quick Reference– Recovery Manager Reference– Recovery Manager User's Guide

Page 36: Oracle Backup and Recovery Using RMAN

More Resources• Oracle Training

– Enterprise DBA Part 1B: Backup and Recovery

• MetaLink Forum – Oracle Server Backup and Recovery/RMAN

Page 37: Oracle Backup and Recovery Using RMAN

Q&A

UW-Platteville Developmenthttp://www.uwplatt.edu/oit/

development

E-mail [email protected]