Oracle Tips by Burleson Consulting
One (if not the, most important) jobs of the Oracle DBA
is to ensure that the databases in their care are protected. Databases, or data
in the database, can be lost through a variety of ways including:
* User error
* Hardware failure
* Software failure
* Application errors
To protect your database, you will need to know how to
back it up and you will need to know how to recover your database. Backup and
recovery is what this last chapter is all about. Backup and recovery can be a
very difficult and complex topic, for there are a number of different options
for you to choose from when it comes to backing up a database. In this chapter,
we aim to set you on the right course, showing you how to perform basic database
backup and recovery operations.
In this chapter we will use the Oracle RMAN tool. It
comes with the Oracle RDBMS and it?s free. In this chapter we will cover:
* Backing up your database with RMAN
* Restoring your database with RMAN
So, without further delay, let?s get started on getting
your database backed up.
Backup Your Database with RMAN
Database backups with RMAN are actually quite easy. Your
database can be in one of two modes, ARCHIVELOG or NOARCHIVELOG mode. The mode
your database is in determines what kinds of backups you can perform on your
database. In this section we will cover the following topics:
The RMAN client is started from the operating system
prompt. To use RMAN, simply set the Oracle environment as you would before you
use any other Oracle client (like SQL*Plus). Once the environment is set, then
you start RMAN as seen in this example:
Once you have started RMAN you will find yourself at the
RMAN prompt. We are then ready to begin our database backup.
Perform an Offline (Cold) Backup of your Database with RMAN
In this section we will show you how to perform an
offline (or cold) backup using RMAN. This will require that the database be down
(that?s why it?s called an offline backup). Oracle supports online backups also,
and we will be covering these shortly.
Before we can use RMAN we need to configure a few
settings. In this section we will look at configuring the database for our
backup, and then we will proceed to do the backup.
Configure Oracle and RMAN for Backup
Before we can use RMAN we will need to configure a few
settings. In this section we will assume:
1. That you will be backing up to a file system called
/u01/app/oracle/backup. You will need to create this file system if it does not
2. That you are using an SPFILE.
Note that if you created your database as we described
earlier in the book, you should already be using an SPFILE.
The configuration is pretty basic. First, we need to
configure a couple of database parameters. These parameters will configure the
Flash Recovery Area of the database.
This is the location that all the disk backups will be
made to. To configure the flash recovery area we will use the alter system
command to set the value of two database parameters:
* db_recovery_file_dest ? Determines the location
of the flash recovery area.
* db_recovery_file_dest_size ? Determines how
much space can be used by Oracle in the flash recovery area.
We will configure the flash recovery area to the value
of /u01/app/oracle/backup, and we will assign it a 2 Gigabyte limit.
Note! Oracle flash
recovery area re-named to fast recovery area
You may need to assign your flash recovery area more
space depending on the following factors:
* The size of your database
* The number of backups you want to keep
* If you are running your database in ARCHIVELOG mode
(which we will discuss later in this chapter).
Here is an example of configuring the flash recovery
area for the settlings listed previously. This assumes your database is using a
SPFILE which we discussed in earlier chapters:
Alter system set
Alter system set
We will also want to set a couple of RMAN settings
before we do our first backup. Start RMAN as detailed earlier in this section
$ rman target /
Now, we want to configure the following:
* Automatic backups of the control file and SPFILE.
* Retention policy to a redundancy of 2
Next, we can use the RMAN configure command to configure
these settings as seen in this example:
Configure the retention policy to redundancy of 2.
means RMAN will try to keep 2 copies of the database backups.
configure retention policy to redundancy 2;
Configure automated backups of the control file and SPFILE.
RMAN>configure controlfile autobackup on;
Now that RMAN and the database are configured, we are
ready to proceed to backup the database.
Also, see my
notes on the different backup types and
the differences between
cumulative and incremental differential backups.
Further RMAN Reading: