Sie sind auf Seite 1von 28

Oracle

Backup & Recovery

Backup and Recovery

Importance of Backup
Terminology

At the functional level, Oracle is simply a collection of


physical data files that reside on one or more hard
drives, such as the hard drive on a PC.
Thus, backing up the system becomes a matter of
knowing which data files to copy to tape or disk
through standard copy utilities.
Oracle constantly updates its database files.

Terminology (Conti.)

Operating System Backup

Terminology (Cont..)

Operating System Backup of Oracle Data


File

Redo Logs

Oracle maintains information concerning


changes, or transactions, in online redo logs.
They specify what changes were made to
information within the database and in what
order.
In the event of an abnormal condition, such as
the database instance being terminated instead
of being properly shut down, the RDBMS uses
information stored within the redo logs to return
the database to its previous, consistent state.
It uses the redo logs cyclically.

Redo Logs (Cont)

It uses the redo logs cyclically.


It shows four 10M redo logs.
This means that the database
instance can write up to 10M of
information to each redo log, at
which point it begins writing to the
next online redo log in the sequence.
When it reaches the final redo log,
the database instance removes all the
information from the first redo log
and begins writing information back
to it.

Archive Log

Consider this disaster scenario: You encounter an


internal error that causes a running Oracle RDBMS
instance to terminate abnormally.
While attempting to bring up the database, you discover
that a media failure has occurred on the disk that
contains the SYSTEM tablespace.
The last backup of the system occurred over four days
ago, and the redo logs have cycled several times since
then.
Oracle cannot do the necessary recovery from its redo
logs to mount and open the database. What do you do?

Archive Log Mode

A database running in ARCHIVELOG


mode functions exactly like one in
NOARCHIVELOG mode.
The only exception occurs when the
database completely fills one redo
log and begins to write information
to the next.
If the redo log contains information
from a previous cyclewhich is true
in all cases except the first cycle
an offline copy of the redo log is
made.
Once this copy is made, the redo
log is emptied and the database
resumes its normal processing by
writing information to the redo log.

Archive Log (Cont.)

This enables you to recover a database by


using the last backup even if it precedes
the earliest information in the redo logs.
Offline redo logs, commonly called archive

logs.

By default, the Oracle RDBMS instance


runs in NOARCHIVELOG mode

Manual Vs Automatic Archiving

Manual Archiving
The DBA controls the
archiving process.
The database must wait for
the DBA to instigate archive,
which can result in database
lockups.
Designing the size,
frequency, and number of
redo logs and cycles
requires additional planning.

Automatic Archiving
The database controls the
archiving process.
Free space and the archive
destination device must be
available. Otherwise, the
database locks up and
waits for the archive.
Handling the volume of
continuous archive logs
requires additional capacity
planning and management.

NoArchiveLog Mode

NOARCHIVELOG mode is the default mode used by


an Oracle RDBMS instance.
In this mode, no archival of the redo logs is made,
and no special handling is required.
However, the DBA needs to guard against disaster
scenarios like the one described earlier
Usually, the only databases run in NOARCHIVELOG
mode are those that do not have a high volume of
transactions, such as decision support databases
that contain only summarized information from
other applications systems.

ArchiveLog Vs NoArchiveLog Mode

ArchiveLog Mode
Additional disk space is
required.
Managing the archive logs
entails additional
administrative overhead.
Hot backups are available.
A complete database
recovery can be performed
in the event of a media
failure.
It is not Default mode of
Oracle Instance.

NoArchiveLog Mode
No additional disk space
required.
No overhead is required.
Only cold backups can be
used.
All the work done since the
last backup is lost in the
event of a failure.
It is Default mode of
Oracle Instance.

Backup Methods

Cold Backup (aka Consistent Backups)

The only way to make a consistent whole database


backup is to shut down the database with the
NORMAL, IMMEDIATE, or TRANSACTIONAL options
and make the backup while the database is closed.
Advantage : No recovery is required after datafiles
are restored quicker restore
Disadvantage : No access to database during backup
time (depends on size/system speed)

Backup Methods (contd)


Cold Backup

Steps in Performing a Cold Backup

A cold backup is the simplest of all backup


operations. The steps required are
1. Shutdown the Oracle database instanceeither
normal or immediate mode.
2. Copy all the physical files associated with the
databasecontrol files, redo log files, and
database files.
3. Restart the database when you are done.

Backup Methods (contd)

Hot Backup (aka Inconsistent Backups)

If the database must be up and running 24 hours a


day, seven days a week, then you have no choice but
to perform inconsistent backups of the whole
database. A backup of online datafiles is called an
online backup. This requires that you run your
database in ARCHIVELOG mode.
Advantage : Database remains open during backup
Disadvantage : Large databases may have
performance impact during backup, recovery takes
longer and is slightly more complex

Backup Methods (contd)


Hot Backup

Cold backups concentrate on copying all the physical


files associated with a database instance. Hot backups,
on the other hand, concentrate on the tablespace level.
To do a hot backup, you must place every individual
tablespace into a backup mode (by using the alter
tablespace command), copy the physical database files
that make up the tablespace, and take the tablespace
out of backup mode (by using the alter tablespace
command). You can issue these commands from Oracle
Server*Manager or SQL*Plus.

Backup Methods (contd)


Hot Backup

alter tablespace system begin backup;


alter tablespace system end backup;
When you place a tablespace in backup mode, the
Oracle instance notes that a backup is being performed
and internally
As you know, it is impossible to make an authentic copy of a
database file that is being written to. On receipt of the command to
begin the backup, however, Oracle ceases to make direct changes
to the database file.
It uses a complex combination of rollback segments, buffers, redo
logs, and archive logs to store the data until the end backup
command is received and the database files are brought back in
sync.

Backup Methods (contd)


Hot Backup

Steps in Performing a Hot Backup


A hot backup is a complex operation, because each tablespace
involves a complete backup operation. It makes sense to break the
hot backup into its component parts. The steps in a hot backup are

1. Place the tablespace in backup mode.

2. Copy all the database files associated with the


tablespace.
3. Take the tablespace out of backup mode.
4. Repeat steps 1 through 3 until all the tablespaces have
been backed up.
5. Copy the control file.
6. Copy the online redo logs.

Backup Methods (contd)


Alternative Backup Methods

Export
Tablespace Offline Copy

Backup Methods (contd)

Logical backup (Export)

Logical backups are exports of schema objects, like


tables and stored procedures, into a binary file.
Oracle utilities are used to move Oracle schema
objects in and out of Oracle.
A popular method for supplemental database backup is the exp
utility, which performs exports of data within the Oracle
database.

Not recommended for backup of a whole database,


but useful for backing up individual objects or
schemas or moving data into another database

Backup Methods (contd)


Export

The exp utility can perform three types of data exports:

Incremental exports:

All the information that has changed since this last incremental
export is exported.
Cumulative exports:

All the data that has changed since the last cumulative export is
exported. A cumulative export is a collection of incremental exports.

Full exports:

All the data within the database is exported.

Backup Methods (contd)


Export

If an export is used for recovery, everything in the


database that has been added, deleted, or otherwise
changed since the last export is lost.

For this reason, exports are used only to facilitate quick, pointin-time recoveries, such as when a static reference table is
truncated. They do not provide the level of recovery that most
mission-critical operations require.
exp file=/tmp/exp.log full=y

Backup Methods (contd)


Tablespace Offline Copy

Of the supplemental backup methods, the tablespace


offline copy method is the only one that can feasibly be
used in production.
It is something of a hybrid between a cold backup and a
hot backup.
It enables you to do essentially a cold backup of a
tablespace while the database remains online.

Backup Methods (contd)


Tablespace offline copy

In the tablespace offline copy method, each individual


tablespace is taken offline by an alter tablespace
command issued from Oracle Server*Manager or
SQL*Plus:

alter tablespace users offline;


alter tablespace users online;

Backup Methods (contd)


Tablespace offline copy

The steps in a tablespace offline copy backup


are
1. Alter the tablespace offline.
2. Perform operating system copy of the database
files associated with the tablespace.
3. Alter the tablespace online.
4. Repeat steps 1 through 3 until all the
tablespaces have been backed up.
5. Back up the control files.
6. Back up the online redo logs.

Backup Methods (contd)


Tablespace offline copy

This method permits a complete hot-style


backup of the individual tablespaces but without
the additional activity within the redo logs,
rollback segments, and so on.
By using this method, you can take a backup of
a tablespace and use archive logs to recover any
transactions that occurred after the backup.

Backup Methods (contd)


Tablespace offline copy

Drawbacks:

Database objects on the tablespace are


unavailable while it is being copied. This is in
direct contrast to the hot backup, in which a
tablespace and its objects remain online and
accessible. Likewise, you cannot back up the
SYSTEM tablespace with this method because it
cannot be taken offline.
You must use another backup method to do
that.

Das könnte Ihnen auch gefallen