Backup and Recovery Introduction to Backup A backup is a copy of data. This copy can include important parts of the database, such as the control file and datafiles. A backup is a safeguard against unexpected data loss and application errors. If you lose the original data, then you can reconstruct it by using a backup. Whole Database Backups A whole database backup is a backup of every datafile in the database, plus the control file. Whole database backups are the most common type of backup. Whole database backups can be taken in either ARCHIVELOG or NOARCHIVELOG mode. Before performing whole database backups, however, be aware of the implications of backing up in ARCHIVELOG and NOARCHIVELOG modes
Tablespace Backups A tablespace backup is a backup of the datafiles that constitute the tablespace. For example, if tablespace users contains datafiles 2, 3, and 4, then a backup of tablespace users backs up these three datafiles. Tablespace backups, whether online or offline, are valid only if the database is operating in ARCHIVELOG mode. The reason is that redo is required to make the restored tablespace consistent with the other tablespaces in the database.
Datafile Backups Chapter 10 | backup and recovery
A datafile backup is a backup of a single datafile. Datafile backups, which are not as common as tablespace backups, are valid in ARCHIVELOG databases. The only time a datafile backup is valid for a database in NOARCHIVELOG mode is if: •
Every datafile in a tablespace is backed up. You cannot restore the database unless all datafiles are backed up.
•
The datafiles are read only or offline-normal
Control File Backups •
Backing up the control file is a crucial aspect of backup and recovery. Without a control file, you cannot mount or open the database.
Archived Redo Log Backups Archived redo logs are essential for recovering an inconsistent backup. The only way to recover an inconsistent backup without archived logs is to use RMAN incremental backups. To be able to recover a backup through the most recent log, every log generated between these two points must be available. In other words, you cannot recover from log 100 to log 200 if log 173 is missing. If log 173 is missing, then you must halt recovery at log 172 and open the database with the RESETLOGS option. Because archived redo logs are essential to recovery, you should back them up regularly. If possible, then back them up regularly to tape. You can make backups of archived logs by using the following methods: •
The RMAN BACKUP ARCHIVELOG command
•
The RMAN BACKUP ... PLUS ARCHIVELOG command
•
An operating system utility
Chapter 10 | backup and recovery
When to Use Import/Export Utilities Recovery In contrast to physical backups, 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. Export, or Data Pump Export, writes data from an Oracle database to binary operating system files. Import, or Data Pump Import, reads export files and restores the corresponding data into an existing database. exp <user_name> /<pass_word> Export options: file,roes,indexes,constraints,owner,tables,full.
imp <user_name> /<pass_word> Import options: file,roes,indexes,constraints,owner,tables,full.
Chapter 10 | backup and recovery