Database Backup   «Prev  Next»

Lesson 2Export and Import utility overview
ObjectiveDescribe functions of Export and Import utilities

Oracle Export-Import Utility Overview

Why do the Export and Import utilities exist, and why should you bother using them?
With so many other utilities becoming available and the changes to Oracle Enterprise Manager, you would think that these utilities would slowly disappear. Perhaps in time they will, but it is much more likely that they will be fully incorporated in other products. For the time being, these utilities do exist, are free, and are part of the Oracle Oracle Certified Professional (OCP) backup and recovery exam.
  • Backup Types
    Let us review some basic information. You can perform two types of backups:
    1. logical and
    2. physical.
    Logical backups copy information from your database to a file with no regard to the physical location of data. Physical backups copy information from your database to a file with physical block location information of the database stored as part of the backup file. Export will perform a logical backup of database objects and/or data to a physical binary file in a special Oracle format. Import will then read the file created by Export and insert database objects and/or data into an Oracle database.

The following diagram explains the use of Export and Import utilities:
Export Import Mouse database operations
The image represents a database backup architecture labeled as Database - orc 1, which suggests an Oracle database instance. It depicts five key backup and recovery components in the form of stacked disks within a cylindrical database representation. Below is an analysis of each component:
  1. Transportation: Easily transports objects from one database to another.
    • This refers to data transportability, which enables the movement of database files or tablespaces between different Oracle database instances.
    • In Oracle, Transportable Tablespaces (TTS) and Data Pump (with EXPDP and IMPDP) are common methods for transporting data efficiently.
  2. Base Level Definition: Create a base level definition of your database.
    • Likely represents the full database backup, which serves as the foundational backup copy.
    • In Oracle, this could be implemented using RMAN (Recovery Manager) full backups, ensuring a complete baseline for recovery.
  3. Disk Fragmentation: Eliminate disk fragmentation.
    • This highlights the issue of disk-level fragmentation, which can impact database performance by causing inefficient I/O operations.
    • Oracle's Automatic Storage Management (ASM) and tablespace reorganization techniques help in minimizing fragmentation.
  4. Selected File Restore: Quickly restore database components in some situations.
    • This represents the ability to restore specific files (such as tablespaces, control files, or redo logs) rather than the entire database.
    • In Oracle, RMAN allows partial restoration, targeting specific components instead of a full database restore.
  5. Data Block Corruption: Detect data block corruption.
    • Addresses corrupted database blocks, which can result in data loss or inconsistencies.
    • Oracle provides mechanisms like DBMS_REPAIR, RMAN Block Media Recovery, and Automatic Block Repair to fix corrupted blocks.
Conclusion This image illustrates essential backup and recovery mechanisms for Oracle databases, ensuring data integrity, transportability, optimized storage management, selective recovery, and corruption handling. These components are crucial for disaster recovery planning and high availability architectures in database environments.

Implementation of Backup and Recovery Components in Oracle 19c

Oracle 19c provides a robust set of tools and techniques for implementing "backup, recovery, and data integrity management".
Below is an in-depth look at how each of the five components is handled:
1. Transportation (Data Movement in Oracle 19c)
Oracle 19c supports several methods for "transporting data" across different database environments:
Easily transports objects from one database to another.
Easily transports objects from one database to another.

Key Features and Implementation:
  • Transportable Tablespaces (TTS)
    • Moves tablespaces between Oracle databases.
    • Involves making the tablespace read-only, using expdp to export metadata, and importing it into the target database with impdp.
    • Example:
      ALTER TABLESPACE users READ ONLY;
      expdp system/password dumpfile=tts.dmp transport_tablespaces=users directory=DATA_PUMP_DIR;
      
  • Data Pump Export/Import (expdp/impdp)
    • Provides fast data transfer between databases.
    • Supports parallel processing for large datasets.
    • Example:
      expdp system/password schemas=hr directory=DATA_PUMP_DIR dumpfile=hr.dmp logfile=hr.log
      impdp system/password schemas=hr directory=DATA_PUMP_DIR dumpfile=hr.dmp logfile=hr_import.log
      
  • GoldenGate Replication
    • Enables real-time data replication across databases.
    • Used for zero-downtime migration and high availability.

2. Base Level Definition (Full Backup in Oracle 19c) A "full backup" provides a "base-level copy" of the database, which serves as the foundation for incremental backups and disaster recovery.
Base level database definition: Create a base level definition of your database.
Base level database definition: Create a base level definition of your database.

Key Features and Implementation:
  • RMAN Full Backup
    • Used to take a complete backup of the database.
    • Example:
      RMAN> BACKUP DATABASE FORMAT '/backup/DB_%U.bkp';
      
  • Incremental Backup Strategy
    • Allows backing up only changed blocks since the last full backup.
    • Example:
      RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE;
      
  • Fast Recovery Area (FRA)
    • Provides automated space management for backups.
    • Example:
                ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 10G;
                ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = '/u01/oradata/recovery';
              

3. Disk Fragmentation (Storage Optimization in Oracle 19c)
Fragmentation occurs when database files become scattered, impacting performance. Oracle 19c includes features to optimize "disk storage" and minimize fragmentation.
Eliminate disk fragmentation.
Eliminate disk fragmentation.

Key Features and Implementation:
  • Automatic Segment Space Management (ASSM)
    • Reduces fragmentation by managing space efficiently in tablespaces.
    • Implemented via AUTOALLOCATE:
      CREATE TABLESPACE my_tbs DATAFILE '/u01/oradata/my_tbs.dbf' 
      SIZE 1G AUTOEXTEND ON SEGMENT SPACE MANAGEMENT AUTO;
      
  • Shrink Table to Defragment Space
    • Reduces fragmentation at the table level.
    • Example:
                ALTER TABLE employees ENABLE ROW MOVEMENT;
                ALTER TABLE employees SHRINK SPACE;
              
  • Online Tablespace Defragmentation
    • Reorganizes fragmented tablespaces online using DBMS_REDEFINITION.
    • Example:
                EXEC DBMS_REDEFINITION.START_REDEF_TABLE('HR', 'EMPLOYEES', 'EMPLOYEES_NEW');
              

4. Selected File Restore (Granular Data Recovery in Oracle 19c)
Oracle 19c allows "selective recovery of specific database files" (datafiles, control files, or archived logs) without affecting the entire database.
Quickly restore database components in some situations.
Quickly restore database components in some situations.
  • Key Features and Implementation:
    • RMAN File-Level Restore
      • Restores a specific tablespace or datafile.
      • Example:
                      RMAN> RESTORE TABLESPACE users;
                      RMAN> RECOVER TABLESPACE users;
                    
    • Point-in-Time Recovery (PITR)
      • Recovers the database to a specific timestamp or SCN.
      • Example:
                      RMAN> RUN {
                        SET UNTIL TIME '2025-01-01:12:00:00';
                        RESTORE DATABASE;
                        RECOVER DATABASE;
                      }
                    
    • Oracle Flashback Technology
      • Flashback Table (restores specific rows)
      • Flashback Database (rolls back entire DB)
      • Example (Flashback a table):
                      FLASHBACK TABLE employees TO TIMESTAMP (SYSTIMESTAMP - INTERVAL '1' HOUR);
                    

5. Data Block Corruption (Block-Level Recovery in Oracle 19c)
Oracle 19c includes "corruption detection and automatic block repair mechanisms" to ensure data integrity.
Detect data block corruption.
Detect data block corruption.

Key Features and Implementation:
  • DBMS_REPAIR to Identify and Fix Corrupt Blocks
    • Detects corrupt blocks and logs them.
    • Example:
      EXEC DBMS_REPAIR.ADMIN_TABLES(TABLE_NAME => 'CORRUPT_BLOCKS', TABLE_TYPE => DBMS_REPAIR.CORRUPT_BLOCKS);
      EXEC DBMS_REPAIR.CHECK_OBJECT(SCHEMA_NAME => 'HR', OBJECT_NAME => 'EMPLOYEES', REPAIR_TABLE_NAME => 'CORRUPT_BLOCKS');
      
  • RMAN Block Media Recovery
    • Recovers corrupted blocks automatically.
    • Example:
      RMAN> BLOCKRECOVER DATAFILE 5 BLOCK 1024;
      
  • Automatic Block Repair in Data Guard
    • In Oracle Data Guard, corrupted blocks are automatically fetched from a standby database and replaced.


Summary Table
Component Implementation in Oracle 19c
1. Transportation Transportable Tablespaces, Data Pump, Oracle GoldenGate
2. Base Level Definition RMAN Full Backup, Incremental Backup, FRA
3. Disk Fragmentation ASSM, Shrink Table, Online Tablespace Defragmentation
4. Selected File Restore RMAN Tablespace Restore, PITR, Flashback Table
5. Data Block Corruption DBMS_REPAIR, RMAN Block Recovery, Automatic Block Repair

Conclusion: Oracle 19c provides advanced backup, recovery, and corruption handling mechanisms to ensure data integrity, transportability, and performance optimization. Whether it's transporting tablespaces, managing storage fragmentation, or recovering corrupted blocks, Oracle's features allow DBAs to implement reliable disaster recovery solutions.

Oracle Database 11g Release 2 (11.2), database backups can be performed using several methods

For Oracle Database 11g Release 2 (11.2), database backups can be performed using several methods,
  1. Data Pump utilities (expdp and impdp)
  2. physical backup techniques like Recovery Manager (RMAN).

We will begin with the "Data Pump" and also outline other common approaches for a complete picture of backup options in 11g R2.

1. Logical Backup with Oracle Data Pump (expdp and impdp)


Data Pump, introduced in Oracle 10g and fully supported in 11gR2, is a powerful tool for logical backups. It exports database objects (i.e., tables, schemas, or the entire database) into a dump file, which can later be imported into the same or a different database.
How to Perform a Data Pump Backup:
  • Export with expdp:
    1. Set up a directory: Create a directory object in the database where the dump file will be stored.
            CREATE DIRECTORY dpump_dir AS '/u01/backup';
            GRANT READ, WRITE ON DIRECTORY dpump_dir TO <username>;
          
    2. Run the export: Use the expdp command from the command line. For example, to back up an entire schema:
            expdp system/password@orcl schemas=HR directory=dpump_dir dumpfile=hr_backup.dmp logfile=hr_exp.log
          

    • schemas=HR: Exports the HR schema.
    • directory=dpump_dir: Specifies the directory object.
    • dumpfile=hr_backup.dmp: Name of the output dump file.
    • logfile=hr_exp.log: Log file for the export process.
    3. Full database export: For the entire database (requires DATAPUMP_EXP_FULL_DATABASE role):
    expdp system/password@orcl full=Y directory=dpump_dir dumpfile=full_backup.dmp logfile=full_exp.log
    

  • Import with impdp:
    If you need to restore the backup:
    impdp system/password@orcl directory=dpump_dir dumpfile=hr_backup.dmp logfile=hr_imp.log
    

    You can also remap schemas, tablespaces, or other objects during import if needed (e.g., remap_schema=HR:HR_NEW).
    Advantages of Data Pump:
    • Faster than the older exp/imp utilities.
    • Supports parallel processing (e.g., parallel=4).
    • Allows filtering (e.g., include=TABLE:"LIKE 'EMP%'") and transformations during export/import.
    Limitations:
    • Logical backups only, this does not capture physical files (e.g., redo logs, control files).
    • Not ideal for point-in-time recovery (PITR).

2. Physical Backup with RMAN (Recovery Manager)


For comprehensive backups in Oracle 11gR2, RMAN is the recommended tool. It performs physical backups of database files (datafiles, control files, archived redo logs) and supports full, incremental, and point-in-time recovery.
How to Perform an RMAN Backup:
  1. Start RMAN: Connect to the target database.
    rman target /
    
  2. Configure settings (optional): Set up defaults like backup location or retention policy.
          CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
          CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u01/backup/backup_%U';
        
  3. Run a full backup:
          BACKUP DATABASE PLUS ARCHIVELOG;
        
    • PLUS ARCHIVELOG: Includes archived redo logs for consistency.
    • Add TAG 'FULL_BACKUP_FEB2025' for easy reference.
  4. Incremental backup (optional): Reduces backup size by capturing only changes since the last backup.
          BACKUP INCREMENTAL LEVEL 1 DATABASE;
        
Advantages of RMAN:
  • Supports full and incremental backups.
  • Integrates with Oracle’s recovery catalog for tracking.
  • Enables PITR and disaster recovery.
  • Can back up to disk or tape.

Example Output Files:
  • Datafiles: /u01/backup/backup_1q2r3s4t_1_1
  • Control file: Included with BACKUP DATABASE or explicitly via BACKUP CURRENT CONTROLFILE.

3. Legacy Export/Import (exp and imp)


Though deprecated in 11gR2, the original 1) exp and 2) imp utilities are still available for backward compatibility.
  • Export:
    exp system/password@orcl file=/u01/backup/hr.dmp owner=HR log=hr_exp.log
    
  • Import:
          imp system/password@orcl file=/u01/backup/hr.dmp fromuser=HR touser=HR log=hr_imp.log
        
  • Note: Oracle recommends Data Pump over these tools due to performance and feature limitations.


4. Cold Backup (Manual)


A simple but less common method involves shutting down the database and copying its physical files.
  1. Shut down the database:
    SHUTDOWN IMMEDIATE;
    
  2. Copy datafiles, control files, and redo logs to a backup location (e.g., /u01/backup).
  3. Restart the database:
    STARTUP;
    
  • Use Case: Rarely used in production due to downtime requirements.

Recommendations for 11gR2:
  • Use RMAN for physical backups and recovery, especially in production environments.
  • Use Data Pump for logical exports (e.g., schema migration or table-level backups).
  • Combine both for a robust strategy: RMAN for disaster recovery, Data Pump for object-level portability.

SEMrush Software 2 SEMrush Banner 2