Oracle Database Backup Information

Contents

Options

A quick review of Oracle backup and recovery options.
 

Backup Modes

Backup Types

 

 

 

 

Logical

Physical

Offline

Online

Export

Y

 

 

Y

Cold

 

Y

Y

 

Hot 

 

Y

 

Y

Online backups are performed while the database is still running, off-line backups are performed while the database is down. Logical backups can also be used for migrating between database versions and Oracle platforms. In Oracle these are performed using the IMPORT/EXPORT utilities.

Backup Modes

a) Offline or Cold Backup

Copying of the datafiles, control file and online redo log files must be done by using an operating system copy utility. This is a considered as a complete backup of the database. Any changes made after this backup will be unrecoverable if the database is running in NOARCHIVELOG mode. All transactions are recorded in online redo log files whether archiving or not. When redo logs are archived (ARCHIVELOG mode), ORACLE allows you to apply these transactions after restoring files that were damaged (assuming an active Redo log file was not among the files damaged). Whenever the schema of the database is changed i.e., a new datafile is added or a file is renamed or a tablespace is created or dropped, shutdown the database and at least make a copy of the control file and the newly added datafile. A complete backup of the database is preferred.

Procedure
1. Backup the control file to trace file.
2. Shut down application (where applicable).
3. Shut Oracle down cleanly. If a SHUTDOWN ABORT has been issued, the instance must be restarted and closed again.
4. Copy all relevant database files to a staging area. These comprise:

5. Restart database.
6. Copy files created to offline storage media (i.e. tape). Ideally these copies will be left on disk to minimise the time taken to recover the database.
 

b) Online or Hot Backup

At sites where database must operate 24 hours per day and when it is not feasible to take offline backups, then an alternative is provided by ORACLE to perform physical backups while the database remains available for both reading and updating. For this kind of backup the database must be in ARCHIVELOG mode. Only data files and current control file need to be backed up. Unlike offline backups, the unit of a online backup is tablespace, and any or all tablespaces can backed up whenever needed. Different datafiles can be backed up at different times. This process should be fully automated if possible. You MUST NEVER BACKUP THE ONLINE REDO LOG FILES ON HOT BACKUPS!!!

 Procedure:

Not all data files need be backed up in this operation, for example read-only tablespaces only need to be backed-up once after the tablespace is made read-only. All of the above processing can be performed while the database is open. Ideally it should occur during a period of low transaction activity.

What happens between BEGIN BACKUP and END BACKUP?

Once the ALTER TABLESPACE ts_name BEGIN BACKUP is issued, two things happen:

(1) Extra information is recorded in the redo logs. Because of this, is it important that on-line backups are done as quickly as possible, and also, if possible, during a quieter period when there is less update activity on the database.

(2) The status in the datafile header is changed to indicate that the datafile is being backed up. Oracle stops recording the occurrence of checkpoints in the header of the database files. This means that when a database file is restored, it will have knowledge of the most recent checkpoint that occurred BEFORE the backup, not any that occurred during the backup. This way, the system will ask for the appropriate set of redo log files to apply should recovery be needed. Since vital information needed for recovery is recorded in the Redo logs, these REDO LOGS are considered as part of the backup. Hence, while backing up the database in this way the database must be in ARCHIVELOG mode. Status in the datafile header is not reset until END BACKUP is issued.

On END BACKUP, the system ceases writing this extra information to the redo-logs, and recommences noting the occurrence of the checkpoints in each file of the database. The checkpoint in the datafile header is changed during the next log switch after END BACKUP is issued. The above information will allow the tablespace to be recovered as if the database had been offline when the backup took place.

Which files to backup

All the files belonging the database are important. Also backup the control file and datafile immediately after adding it to a tablespace or after creating tablespace if archiving is enabled. If media failure damages a datafile that has not been backed up, recovering its tablespace is not possible. After backing up the newly added datafile, include it in the regular datafile backup rotation.

Identifying the files to backup: Use the 'v$' (dynamic performance tables) to find the file names:

select name from v$datafile
UNION
select name from v$controlfile
UNION
select member from v$logfile;

Archive Log Mode

Archiving is the process of writing data from a filled online redo log file to an archive log file.
An Oracle database can operate in either NOARCHIVELOG or ARCHIVELOG mode. Oracle writes to the current online redo log file until it fills up, it then begins writing to the next one. When the last online redo log file is full, Oracle cycles back to the first one. In ARCHIVELOG mode each log file is saved before being overwritten. The archive process will backup each redo log file as soon as it is filled. The ARCHIVELOG function enables a whole range of possible backup options:

Points to note:

Recommendations:

NOARCHIVELOG:

Implement a Backup strategy

Its important to identify exactly what recovery facilities are required by the site This will determine the frequency and type of backup that will have to be taken. The answers to several questions must be established before attempting to implement any backup procedures.

Implementing a backup strategy requires consideration of the following.

How much data can you afford to lose?
If you can afford to lose up to a day's worth of data, then running in NOARCHIVELOG mode and taking nightly off-line backups is sufficient. Any changes applied to the database after the most recent backup will be unrecoverable.
If you cannot afford to lose transactions performed since the last backup then you must run in ARCHIVELOG mode. The archived redo log files contain a record of all transactions applied since the last backup. These transactions can be reapplied after restoring from backup any datafiles that were damaged.

How often and for how long, can the database be off-line to perform backups?
Many sites operate 24 hours per day. Even at sites where the database can be shutdown for maintenance, a complete backup may take longer than the window available. When it is not feasible to take off-line backups often enough to provide the protection from data loss the site requires, then online backups are the only option.

Should recovery be needed, how quickly do you need to recover your data?
The cost of downtime (or database outage) may be a key factor in configuring the backup strategy. Recovery time using:

Logical backups (export) take the longest

Physical backups provide the fastest recovery times.

Do you need the capability to reverse changes made to the database?
Do you wish to be able to protect against inadvertent changes made to both the content and structure of the database. For example, bringing back a dropped table, or removing a datafile added to the wrong tablespace.

How to minimize vulnerabilities during backup and recovery?

How can physical and logical errors be monitored and checked for?

Guidelines for scheduling Routine backups

Implement Non-routine Backups

Non routine backups are required in the following circumstances:

Performance

Backup and recovery performance can be improved using the following guidelines:

Implementing a Backup Strategy Using ARCHIVELOG

 
Procedures to enable Archiving Log Mode

Enabling automatic archiving (init.ora) method, Connect to sqlplus as SYS and perform the following:
create pfile form spfile;
Edit the init.ora File and add the following lines:
*.
Log_archive_start    = True
*.Log_archive_format = "ARCH_%t_%s_%r.dbf"
l*.og_archive_dest_1 = "location=/u01/oradata/TICPBT09/ARCH MANDATORY"
*.log_archive_dest_state_1 = enable
*.log_archive_dest_2 = "service=TICPBP02 OPTIONAL reopen=60"
*.log_archive_dest_state_2 = enable
*.log_archive_min_succeed_dest = 1

For 10g

The LOG_ARCHIVE_START init.ora parameter has been rendered obsolete. In Oracle 10g, if the LOG_ARCHIVE_DEST is not set, archiving will be directed to the flashback recovery area automatically when the database is switch to ARCHIVELOG mode.
*.log_archive_format='ARCH_%t_%s_%r.dbf'
*.log_archive_dest_1='LOCATION=/u02/oradata/ARCH'
*.log_archive_dest_state_1 = enable
*.log_archive_dest_2 = "service=TICPBP02 OPTIONAL reopen=60"
*.log_archive_dest_state_2 = enable
*.log_archive_min_succeed_dest = 1

Shutdown the database:
shutdown immediate;