Vous êtes sur la page 1sur 30

5

Using Recovery Manager

Copyright 2004, Oracle. All rights reserved.

Objectives
After completing this lesson, you should be able to do
the following:
Use the RMAN BACKUP command to create backup
sets and image copies
Manage the backups and image copies taken with
RMAN

5-2

Copyright 2004, Oracle. All rights reserved.

Issuing Recovery Manager Commands

Interactive client
Type commands at RMAN prompt
Use when doing analysis, running reports or stored
scripts

Batch mode
Use with automated jobs
Specify a command file when starting RMAN
Set the log file to obtain information

Pipe interface
Specify the PIPE command line argument
Use to communicate data between sessions or
between RMAN and an external application

5-3

Copyright 2004, Oracle. All rights reserved.

RMAN Command Overview


Restore/Recover/Flashback
Enterprise
Manager

RMAN

Backup
SPFILE
Target
database
Archived
log files

5-5

Control
file

Stored
scripts

Catalog maintenance
CROSSCHECK
DELETEEXPIRED
LIST
CHANGE

Copyright 2004, Oracle. All rights reserved.

REPORT
LIST

Catalog
database

RMAN Commands
RMAN commands are of the following types:
Stand-alone
Executed individually at the RMAN prompt
Cannot appear as subcommands within RUN

Job
Must be within the brackets of RUN
Executed as a group

Stand-alone or job
Can be executed at the RMAN prompt and run
individually
Can be run within the brackets of RUN and executed
within a group

5-6

Copyright 2004, Oracle. All rights reserved.

Job Command: Example


RUN command:
RMAN>
2>
3>
4>
5>
6>

RUN {
BACKUP AS BACKUPSET
FORMAT '/u01/db01/backup/%d_%s_%p'
DURATION 10:00 MINIMIZE LOAD
(DATABASE);
SQL 'alter system archive log current';

7> }

5-7

Copyright 2004, Oracle. All rights reserved.

The BACKUP Command

RMAN> BACKUP AS BACKUPSET


2>
FORMAT '/BACKUP/df_%d_%s_%p.bus'
3>
TABLESPACE hr_data;

Data file
1

Data file
3

Data file
2

Tablespace
HR_DATA

5-8

Data file
1
Data file
2
Data file
3

Backup
set

Copyright 2004, Oracle. All rights reserved.

Backup Constraints

5-9

The database must be mounted or open.


Online redo log backups are not supported.
Only clean backups are usable in NOARCHIVELOG
mode.
Only current data file backups are usable in
ARCHIVELOG mode.

Copyright 2004, Oracle. All rights reserved.

Parallelization of Backup Sets


Allocate multiple channels and assign files to specific
channels.
Data file
1

Data file
4

Data file
5

Channel
MML

Data file
2

Data file
3

Data file
9

Channel
MML

Data file
6

Data file
7

Data file
8

Backup
piece 2

Channel
MML

5-10

Backup
piece 1

Copyright 2004, Oracle. All rights reserved.

Backup
Piece 3

Compressed Backups

RMAN> BACKUP AS
2> COMPRESSED BACKUPSET
3> DATABASE;
Database files

RMAN>
2>
3>
4>

5-12

CONFIGURE DEVICE TYPE


DISK PARALLELISM 2
BACKUP TYPE TO
COMPRESSED BACKUPSET;

Copyright 2004, Oracle. All rights reserved.

Compressed
backup files

Image Copy

RMAN>
2>
3>
RMAN>
4>
5>

5-13

BACKUP AS COPY
DATAFILE '/ORADATA/users_01_db01.dbf'
FORMAT '/BACKUP/users01.dbf' tag=DF3;
BACKUP AS COPY
ARCHIVELOG LIKE 'arch_1060.arc'
FORMAT 'arch_1060.bak';

Data file
3

Data file
3

Copy of data file 3

Archived
log file

Archived
log file

Copy of archived log

Copyright 2004, Oracle. All rights reserved.

Tags for Backups and Image Copies


A tag is a logical name assigned to a backup set or
image copy.
month_full_backup week_full_backup Wednesday_1_backup

5-15

Data files
1,3

Data file
3

Data files
2,4

Data file
4

Backup set

Backup set

Copyright 2004, Oracle. All rights reserved.

Data file
1

Backup set

BACKUP Options

5-16

Check for physical block corruptions


Scan for logical corruptions in addition to physical
corruptions
Set a threshold on the number of detected
corruptions allowed before aborting
Validate the target input files before performing a
backup operation
Duplex the backup set
Overwrite an existing backup set or image copy
Pass control over the data transfer between
storage devices and the data files on disk to the
media management layer
Copyright 2004, Oracle. All rights reserved.

Backing Up Archived Redo Logs

Online redo log file switch is automatic.


Archived log failover is performed.
You can specify a range of archived redo logs to
back up.
Backup sets include only archived redo log files.

RMAN> BACKUP
2>
FORMAT '/disk1/backup/ar_%t_%s_%p'
3>
ARCHIVELOG FROM SEQUENCE=234
4>
DELETE INPUT;

5-18

Copyright 2004, Oracle. All rights reserved.

Copying the Whole Database

RMAN> BACKUP DATABASE


PLUS ARCHIVELOG;

Data file
copies

Archived log
file copies
5-19

Copyright 2004, Oracle. All rights reserved.

Control
file

SPFILE

Making Incremental Backups

5-20

Full backup

A level 0 incremental backup,


similar to a full backup,
contains all data file blocks.
A cumulative level 1
incremental backup contains
only blocks modified since the
last level 0 incremental
backup.
A differential level 1
incremental backup contains
only blocks modified since the
last incremental backup.

Cumulative
incremental backup

Differential
incremental backup

Copyright 2004, Oracle. All rights reserved.

Incremental Backup: Example

A differential incremental backup contains all


blocks changed since the last incremental backup
A cumulative incremental backup contains all
blocks changed since the last level 0 incremental
backup
Level 0

0
Lvl
Day Sun
5-22

Level 0

1c

Mon

Tue

Wed

Thu

Copyright 2004, Oracle. All rights reserved.

1c

Fri

Sat Sun

Block Change Tracking

Records changed blocks in a change tracking file


Is used automatically by RMAN if enabled
Optimizes incremental backups by avoiding full
data file scans during backup
List of changed
blocks

CTWR

SGA

5-23

Redo
generation

1011001010110
0001110100101
1010101110011

Copyright 2004, Oracle. All rights reserved.

Change
tracking
file
Redo log

Enabling Block Change Tracking


SQL> ALTER DATABASE ENABLE
2> BLOCK CHANGE TRACKING
3> USING FILE '/mydir/rman_change_track.f'
4> REUSE;

5-24

Copyright 2004, Oracle. All rights reserved.

Incrementally Updating Backups

Image copy
of data file

Incremental
backup files

RMAN> RECOVER COPY OF


2> DATAFILE {n|'file_name'}
3> WITH TAG 'incr_upd_df1';
Image copy of data file
updated to a more
recent state
Recovered data file
5-25

Copyright 2004, Oracle. All rights reserved.

LIST Command Operations

List backup sets and copies of data files

RMAN> LIST BACKUP OF DATABASE;


RMAN> LIST BACKUP OF DATAFILE
2>
"/db01/ORADATA/u03/users01.dbf";

Lists backup sets and copies of any data file for a


specified tablespace

RMAN> LIST COPY OF TABLESPACE "SYSTEM";

Lists backup sets and copies containing archive


logs for a specified range

RMAN> LIST COPY OF DATABASE ARCHIVELOG


2> FROM TIME='SYSDATE-7';
5-26

Copyright 2004, Oracle. All rights reserved.

The REPORT Command

Produces a detailed analysis of


the repository
Produces reports to answer:
Which files need a backup?
Which backups can be
deleted?
Which files are unrecoverable?

5-27

Copyright 2004, Oracle. All rights reserved.

The REPORT NEED BACKUP Command

Lists all data files that require a backup


Assumes the most recent backup is used during a
restore
Provides four options:

5-28

Incremental
Days
Redundancy
Recovery window

Uses the current retention policy configuration if


no options are specified

Copyright 2004, Oracle. All rights reserved.

REPORT NEED BACKUP: Examples

Files needing three or more incremental backups


for recovery:
RMAN> REPORT NEED BACKUP incremental 3;

Files have not been backed up for three days:


RMAN> REPORT NEED BACKUP days 3;

Backup needed if there are not two or more:


RMAN> REPORT NEED BACKUP redundancy 2;

Backup needed to recover 3 days past:

RMAN> REPORT NEED BACKUP


2>
recovery window of 3 days;
5-29

Copyright 2004, Oracle. All rights reserved.

REPORT OBSOLETE and DELETE OBSOLETE

Find all obsolete recovery files using the current


retention policy settings:
RMAN> REPORT OBSOLETE;

List the obsolete recovery files, if no more than


two backup copies are needed:

RMAN> REPORT OBSOLETE REDUNANCY 2;

Delete the backup set with a backup set key of 4:

RMAN> DELETE BACKUPSET 4;

Delete the recovery files considered obsolete,


because they have more than two backups:

RMAN> DELETE OBSOLETE REDUNDANCY 2;

5-30

Copyright 2004, Oracle. All rights reserved.

Managing Backups with EM

5-31

Copyright 2004, Oracle. All rights reserved.

RMAN Dynamic Views

5-32

V$ARCHIVED_LOG
V$BACKUP_CORRUPTION
V$BACKUP_DEVICE
V$BACKUP_FILES
V$BACKUP_PIECE
V$BACKUP_REDOLOG
V$BACKUP_SET
V$BACKUP_SPFILE
V$COPY_CORRUPTION
V$RMAN_CONFIGURATION

Copyright 2004, Oracle. All rights reserved.

Monitoring RMAN Backups

5-34

Correlate server sessions with channels using the


SET COMMAND ID command.
Query V$PROCESS and V$SESSION to determine
which sessions correspond to which RMAN
channels.
Query V$SESSION_LONGOPS to monitor the
progress of backups and copies.
Use an operating system utility to monitor the
process or threads.

Copyright 2004, Oracle. All rights reserved.

Summary
In this lesson, you should have learned how to:
Use the RMAN BACKUP command to create backup
sets and image copies
Manage the backups and image copies taken with
RMAN

5-36

Copyright 2004, Oracle. All rights reserved.

Practice 5 Overview: Using RMAN


This practice covers the following topics:
Enabling archival of redo logs for a database
Using RMAN to display the database structure
Using Recovery Manager to back up data files and
the control file
Using Recovery Manager to make image copies of
data files
Creating a compressed backup of a database
Scheduling a backup job

5-37

Copyright 2004, Oracle. All rights reserved.