Oracle RMAN 11g Backup and Recovery (86 page)

BOOK: Oracle RMAN 11g Backup and Recovery
5.46Mb size Format: txt, pdf, ePub

Backing Up Only Newly Added Datafiles

Here is a neat option you can use. Suppose you have just added four or five new datafiles to the database, and you want to back them up without having to back up the entire database. You could just back up the individual datafiles (as we will show you later in this chapter), but there is an easier way. You can use the
not backed up
option of the
backup
command, and RMAN will only back up datafiles that have not been backed up. Here is an example: backup database not backed up;

Backing Up Files Not Backed Up in a Specific Time Period

Perhaps you have a backup strategy in which you back up only specific datafiles on specific nights. The
since time
option is also really handy if you need to restart a failed backup. If the backup fails, you can use this option, after you have corrected the cause of the failure, to restart the backup. For example, let’s assume that your tape system died two days ago in the middle of a backup. You finally got the tape system fixed, so how would you restart the backup? Simply issue this command:

backup database not backed up since time 'sysdate - 2';

In this case, RMAN only backs up those datafiles that have not been backed up within the last two days. Note that you can express the time in the format of the database NLS_DATE format, or you can use a SQL date expression such as the one in our example. An additional parameter to

Chapter 11: RMAN Backups
245

the
since time
option applies to archive log backups to ensure that each archive log is backed up a certain number of times before it is removed. We will cover that option later in this chapter.

Some backup strategies include backing up the archived redo logs once, shortly after they are created, and then perhaps later during the nightly backup. Once they are backed up for the nightly backup, they are to be removed. The configured retention defaults don’t really allow you to configure the database to meet this requirement, but we can manually define retention criteria in our
backup
commands. As an example, we can perform this kind of backup using the
backup
archivelog
command and the
backup database
command, as shown here:

-- This command backs up archived redo logs not already backed up.

Backup archivelog all not backed up 1 times;

-- Later in the day, back up the database and archived redo logs, and

-- remove the archived redo logs

backup as compressed backupset database plus archivelog

not backed up 1 times delete input;

Checking for Logical Corruption During a Backup

By default, RMAN checks for physical corruption of database blocks. If any corruption is discovered, the backup will fail. If you want even more error checking, you can configure a backup to check for logical corruption by using the
check logical
option of the
backup
command.

Here are a couple of examples of the use of this option:

backup check logical database;

backup validate check logical database;

NOTE

If you are running your database in a standby database configuration,
Oracle Database 11
g
Release 2 offers automatic repair of corrupt
blocks. If a corrupt block is identified on the standby or primary

database, it will be corrected by using a block from the unaffected

database. See Chapter 15 for more information on this new feature!

The first example physically backs up the database as it is checking for logical corruption.

The second example just validates the database blocks performing a logical database verification without performing an actual physical backup of the database. If you wish the backup to continue through a given number of errors, you need to set the
maxcorrupt
parameter first. This requires using a
run
block, as shown in this example:

run {

set maxcorrupt for datafile 1,2,3,4,5,6,7 to 10;

backup validate check logical database;

}

Making Copies of Backups on Your RMAN Copier

Perhaps you wish to create multiple copies of the backup pieces of a backup set. While this can be configured by default, you can also use the
copies
parameter to configure a specific backup to create multiple copies of the backup pieces. (You could also use the
set backup copies
parameter.) Here is an example of this option in use:

backup database copies 2;

246
Part II: Setup Principles and Practices

Capturing the Elusive Control File

The
include current controlfile
option creates a snapshot of the current control file and places it into each backup set produced by the
backup
command. Here is an example of the use of this command:

backup database device type disk include current controlfile;

By default, if you do a backup of datafile 1, the control file will get backed up anyway. So this parameter comes in much more handy if you are doing tablespace or datafile backups. Furthermore, if automated backup of control files is configured, then this command can cause the current control file to be stored in the backup set also (so you have two copies of the control file, though they might be slightly different if you are running in ARCHIVELOG mode).

Introducing the set Command

We have covered a great deal of material about offline backups. Now that you have some idea of how RMAN commands work when backing up—and before we move on to discuss online backups—we should take a quick detour and look at the RMAN
set
command.

The
set
command is used to define settings that apply only to the current RMAN session. In other words, the
set
command is a lot like the
configure
command (refer to Chapter 3), but the settings are not persistent. You can use the
set
command one of two ways, depending on the
set
command you need to use. You can use it outside a
run
block for these operations:

■ To display RMAN commands in the message log, use the
set echo
command.

■ To specify a database’s database identifier (DBID), use the
set dbid
command.

Certain
set
commands can only be used within the confines of a
run
block. The most common are the following:

■ The
set newname
command is useful if you are performing tablespace point-in-time recovery (TSPITR) or database duplication. The
set newname
command allows you to specify new database datafile names. This is useful if you are moving the database to a new system and the file system names are different. You need to use the
switch
command in combination with the
set newname
command. You will see examples of this in later chapters.

■ Using the
set maxcorrupt for datafile
command enables you to define a maximum number of data block corruptions allowed before the RMAN operation will fail.

■ Using the
set archivelog destination
command allows you to modify the archive_log_

dest_1 destination for archived redo logs.

■ Using
set
with the
until
clause enables you to define a specific point in time, an SCN, or a log sequence number, to be used during database point-in-time recovery.

■ Using the
set backup copies
command enables you to define how many copies of the backup files should be created for each backup piece in the backup set.

■ Using the
set command id
setting enables you to associate a given server session to a given channel.

Other books

His at Night by Thomas, Sherry
The Boyfriend Project by Rachel Hawthorne
A Murder of Magpies by Sarah Bromley
Arresting God in Kathmandu by Samrat Upadhyay
Letters to Penthouse VI by Penthouse International
Black Ice by Matt Dickinson
Gallow by Nathan Hawke
Eva Sleeps by Francesca Melandri, Katherine Gregor
Whiskey Tango Foxtrot by David Shafer