BACKUP AND RECOVERY

Objectives

  • Backup and Recovery Overview

  • Cold Database Backup

  • Hot Database Backup

  • Manual Database Recovery

  • Introduction to RMAN

  • Configuring RMAN

  • Database Backup using RMAN

  • RMAN Database Recovery

ORACLE DATABASE BACKUP AND RECOVERY

  • Backup Definition: Creating a copy of the database's data for restoration in case of failure or data loss.

    • Two types of backups in Oracle: physical and logical.

  • Recovery Definition: Restoring data from backups and applying changes (redo log data) to ensure database consistency after data loss.

REDO LOGS AND ARCHIVE LOGS

  • Redo Logs: Records every change made to the database. Used for recovering uncommitted transactions during a crash.

  • Archive Logs: If in ARCHIVELOG mode, redo logs are archived. This allows for point-in-time recovery by applying archived redo logs.

IMPORTANCE OF BACKUPS

  • Data Loss Prevention

  • Disaster Recovery

  • Data Integrity

  • Business Continuity

  • Compliance and Legal Requirements

  • Historical Data Retrieval

  • Testing and Development

  • Version Control

  • Cost Savings

  • Protection Against Human Errors

TYPES OF BACKUP

  • Backup: A copy of original data to reconstruct it when lost.

  • Physical Backup (OS Backup): Involves copies of database files (data files, control files, redo log files). Essential for full database restoration.

Types of Physical Backups

  • Cold Backup (Offline Backup): Taken when the database is shut down. Ensures consistency with no transactions occurring during backup.

  • Hot Backup (Online Backup): Taken while the database is operational. Oracle guarantees data consistency during the backup process.

Logical Backups

  • Backups of logical structures (tables, indexes, stored procedures).

  • Performed using Oracle's Data Pump (expdp and impdp) or older EXP/IMP utilities.

  • Ideal for restoring individual objects or schemas but insufficient for complete recovery.

BACKUP METHODS

  • User-Managed Backups: DBA manually copies necessary database files using OS commands, performed as hot or cold backups.

  • RMAN (Recovery Manager): Oracle's recommended tool for backup and recovery. Automates most tasks ensuring database integrity.

LOGICAL STRUCTURE OF ORACLE DB

  • Components include:

    • ORACLE HOME

    • Data files

    • Control files

    • Log files

    • Various tables (EMP, Dept)

  • Utilities for logical data backup: Export/Import utility, Data Pump utility.

COLD DATABASE BACKUP

  • Fully consistent backup performed when the database is shut down.

  • No access for users during backup, and no need to back up redo logs or archive redo logs.

  • Utilizes OS-level copy; rarely performed in real-time operations.

When to Carry Out Cold Backup

  • At OS level: Copy files in ORACLE HOME (data files, control files, log files) using utilities.

GROUND RULES FOR BACKUP AND RECOVERY

  1. Keep backup data on a separate drive from original data.

  2. Ensure consistent backup; no changes during backup.

  3. Cold backups require downtime.

  4. Incomplete recovery limits to point of the last backup.

  5. Recovery involves restoring from backup and applying logs.

COLD DATABASE RECOVERY

  • Steps:

    1. Simulate failure (delete all database files).

    2. Copy parameter file, control files, and data files from backup location at appropriate stages (NO MOUNT, MOUNT, OPEN).

  • Incomplete Recovery: Only recover up to the point of the last cold backup.

PERFORMING COLD BACKUP

  • Steps involved:

    1. Determine file locations (control and data files).

    2. Shutdown the database.

    3. Copy files to backup.

    4. Restart database and verify recovery processes.

QUERY FILES FOR RECOVERY

  • Example SQL commands for querying control files and data files post-recovery.

LAST BACKUP

  • Demonstrates creation of a table and insertion of records with a commit to showcase last backup state.

COLD DB RECOVERED

  • SQL queries to verify database recovered correctly after performing a cold backup recovery.

TYPES OF BACKUP

  • Consistent Cold Backup: Requires no recovery.

  • Inconsistent Hot Backup/RMAN Backup: Requires recovery.

RECOVERY METHODOLOGY

  • Restore or copy from backup and recover using archive redo logs.

HOT DATABASE BACKUP

  • Inconsistent backup taken while the database is running and requires no downtime.

  • Database must be in ARCHIVELOG mode for hot backups.

HOT DATABASE BACKUP AND RECOVERY

  • Steps:

    1. Begin backup mode and copy files at OS level.

    2. End backup mode and backup archive logs post-recovery simulation.

    3. Verify if the new user/dummy table exists post-recovery.