Oracle RMAN 11g Backup and Recovery (81 page)

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

232
Part II: Setup Principles and Practices

NOTE

Oracle only supports backups of SPFILEs. You cannot back up your

database text-based init.ora parameter file with RMAN.

Finally, we might have opted to connect to the recovery catalog when we did this backup (and this applies to all backups that we do in this chapter). To connect to the recovery catalog, all you need to do is add the
catalog
parameter when starting RMAN: C:\>set oracle sid recover

C:\>rman target backup admin/Robert catalog rcat owner/password@robt

One interesting thing to note here is that when we connected to our recovery catalog owner, we did so using Oracle Net because we had our ORACLE_SID set to the SID of our database rather than the SID of the recovery catalog. When you do a backup with a recovery catalog, you need to use a service name and Oracle Net to connect either to the database you are backing up or to the catalog. We generally recommend using the networking connection to connect to the catalog and connecting directly to the database if possible.

Also, note that if we had not configured automated backups of our control file, RMAN would still back up the control file as long as we were backing up datafile 1. The control file would be backed up into the backup set that contains datafile 1. You would also want to do a separate control file backup after your database backup was complete, so you would have the most current control file backed up (because the control file backed up with the backup set will not have the complete information on the current backup in it). Note that this control file, if it must be recovered, is a bit more complicated to recover if you have not configured control file autobackups.

Because of this, we strongly suggest that you configure control file autobackups on your system.

Offline Backups Without Using Configured Defaults

What if we had not configured default settings (see Chapter 3)? Or what if the defaults were not what we wanted to use (maybe we don’t want to back up to the FRA)? In this case, we have a few more things that we need to do. Let’s look at an example of such a backup and determine what it is doing:

shutdown

startup mount

run

{

allocate channel c1 device type disk format 'd:\backup\robt\robt %U';

allocate channel c2 device type disk format 'c:\backup\robt\robt %U';

backup as compressed backupset database;

backup current controlfile;

}

The next few sections look at this example in a bit more detail.

In the Beginning, Shut Down and Mount the Database

This example looks a bit more complicated than the earlier example. First, we have the
shutdown
and
startup mount
commands that we had in the previous example. These are required for any offline backup. We will discuss online backups later in this chapter.

Chapter 11: RMAN Backups
233

Run, Oracle, Run!

Next, we have a
run
block, which is a set of one or more statements, contained within the confines of braces of a
run
command, that are executed together as a block. Oracle will not run any of the statements until the entire block of statements has been entered. After you have entered all the statements, you complete the
run
block with the closing brace (followed, of course, by pressing ENTER). The
run
block is then compiled and executed.

NOTE

This book was written using Oracle Database 11
g
Release 2. In this
release of RMAN (and 9
i
and 10
g
, in general), many commands that
previously had to run within the confines of a
run
block no longer
need to. We deliberately do not use
run
blocks unless required by this
release. Many of the backup and restore/recover commands you will

see in this and the next chapter will work in previous versions, but
need to be run within a
run
block.

Allocate Channels

In the preceding code example, we have several different RMAN commands in the
run
block.

First, the
allocate channel
commands each allocate a channel to RMAN for the database backup.

We have discussed channels already (in Chapter 3, for example), but let’s look into their use a bit more for a moment.

First, a word on backup sets and backup set pieces. Each time we create a channel, this implies that we are going to create one or more backup sets. There are some exceptions to this statement, but generally this is true, so for the sake of this discussion, assume this is a true statement.

Let’s quickly define some terms:


Backup sets
Logical entities, one or more of which will be created for each channel you define (generally, it’s one backup set per channel).


Backup pieces
The actual physical files that the backed up data resides in. One or more backup pieces may be associated with each backup set.

You can control the overall backup set size with the
backup
command (or, alternatively, you can configure a default value for it), or you can control the overall backup piece size with the
allocate channel
command (again, this can be configured when you configure default channels).

We will further discuss limiting backup set sizes later in this chapter.

The
allocate channel
command defines to which device a given channel (and thus, an individual backup set) is to be allocated. This device might be a disk (type
disk
) or a tape drive (type
sbt
). If we were allocating a channel to a tape system, we might also include certain parameter settings required by the MML vendor that we were using. An example of an
allocate
channel
command to tape using an MML vendor, VERITAS NetBackup, might look like this: allocate channel t1 type sbt parms 'ENV (NB ORA CLASS RMAN db01)';

This particular channel is being allocated to a tape device. Refer to Chapters 4 through 10, which discuss topics related to non-disk backup location, for more on allocating RMAN channels to MML devices, Amazon S3, and Oracle Secure Backup. Having allocated two channels to the backup, RMAN will automatically try to parallelize the backup stream among those channels.

234
Part II: Setup Principles and Practices

Thus, since we have allocated two channels, two different backup sets will be created, and each backup set will have one backup piece. The size is defined in bytes, but you can use the
k, m,
or
g
specifications to indicate kilobytes, megabytes, or gigabytes, respectively, as required. Here is another example of the
allocate channel
command:

allocate channel t1 type disk maxpiecesize 100m;

In this example, we have limited to 100MB the maximum size of each individual piece of a backup set (remember that each channel will create a single backup set) created through that channel. This is a great way to ensure that you do not create an individual backup piece that is larger than your tape or file system can handle.

Here is another example:

allocate channel t1 type disk maxpiecesize 100m

format 'd:\backup\robt\robt %U.bak'

In this example, we have used the
format
parameter to define where the backup pieces will be put on the disk and what the naming convention will be for the backup pieces. Since we use the
format
parameter, we are essentially telling RMAN not to use the default location for the backup set pieces (which is typically the FRA).

Note the %U format placeholder in the
format
command. Since we are not backing up to the FRA, we need to define the file naming convention associated with the backup pieces that will be created; in this case we use the %U format indicator. The resulting name will include the database name (robt) followed by an underscore and then an eight-character mnemonic that consists of the following:

■ The backup set identifier. Each backup set is assigned a unique identifying number by RMAN when it is created.

Other books

Enemies at the Altar by Melanie Milburne
Kade Loves Alex by Holder, Krystal
HMS Diamond by Tom Grundner
Lizzie's Secret by Rosie Clarke