*Oracle 19c – RMAN and Data Pump
*

Physical Database Backup, Logical Database Export and Database Disaster Recovery for Oracle DBAs

Technology: Oracle 19c Database

Tools: Oracle Recovery Manager (RMAN), Data Pump Export (EXPDP), Data Pump Import (IMPDP)

Professionals: Oracle DBA(s), Database Engineer(s), IT Operations staff.

Introduction

Ensuring that database data is secure and can be recovered is a core function of an Oracle DBA.

Within Oracle, there are various technologies available for securing and transferring data, and two popular tools are RMAN and Oracle Data Pump (EXPDP/IMPDP).

Whilst both can produce files representing database data, they function and are utilised in distinct ways.

Suppose that you have generated an RMAN backup together with a Data Pump export of an Oracle 19c database.

Could both be utilised for data recovery?

What would happen if the total database were lost?

Or, if a key database table had been incorrectly deleted?

Can backups be transferred to another database server?

Which is preferable for transitioning from an older version of Oracle to 19c?

Is it necessary to utilise both RMAN and Data Pump?

Understanding these areas is crucial for formulating a robust database backup, recovery and transfer solution.

  1. Oracle RMAN

Oracle's native physical database recovery and backup tool is known as RMAN.

It interacts with Oracle database and recovery data.

Depending upon how RMAN is configured, it can back up database datafiles, control files, archived redo logs and the server parameter file.

Primarily, RMAN is used to allow for the recovery of a database or parts of a database following issues such as:

Storage related issues.

Misplaced or corrupted datafiles.

Database corruption.

Unwanted data modification necessitating assisted point-in-time recovery.

Replacement of database and/or storage hardware.

Disaster recovery.

How RMAN functions

Below is a basic outline of how data is backed up by RMAN:

 Oracle Database | v RMAN reads Oracle data blocks | v RMAN creates backup sets or image copies | v Backup storage | v RMAN restore and recovery 

Using 'backup sets’, RMAN produces backup files in Oracle's proprietary format.

Alternatively, for ‘image copies’, RMAN will copy database data files and present them in the correct physical format.

In addition to this, RMAN stores metadata about performed backups. This is held in the database's control file and can also be stored in a secondary 'recovery catalog’.

Restore and Recover

Within Oracle, 'restore' and 'recover' have distinct meanings.

RESTORE

Transfers database data files from a physical database back-up to a designated location.

RECOVER

Applies relevant redo data so that the restored files are transactions consistent at the required recovery point.

For example:

 Database datafile lost | v RESTORE the datafile from an RMAN backup | v RECOVER the datafile using required redo | v Database available again 

This will depend on the nature of the issue, the required recovery, accessibility of back-ups and redo archives together with the database's condition.

Different commands will often be required for different recoveries.

  1. Oracle Data Pump

This Oracle tool is used for logically exporting and importing database data and objects.

The main command line interfaces are:

EXPDP – Data Pump Export

Used to export database data and objects to a Data Pump 'dump file set’.

IMPDP – Data Pump Import

Imports nominated database objects and data from a Data Pump export to a compatible Oracle database environment.

Generally:

 Source Database | v EXPDP | v Data Pump dump files | v IMPDP | v Target Database 

Data Pump works in a logical manner.

It can export database objects, such as tables, table data, indexes and constraints, together with further types of database object metadata where supported.

The precise database objects exported will vary depending on the export type, privileges and configuration together with the types of database object that can be exported.

Common situations for which Data Pump is well suited include:

Transferring a database schema from one database to another.

Exporting particular database tables.

Producing a logical copy of application data.

Assisting in a database transition.

Refreshing a test database.

Transferring compatible data between differing Oracle database versions.

Maintaining logical exports for certain recovery scenarios.

There are a number of Data Pump export types, for instance full, schema, table and tablespace exports.

Nevertheless, a full Data Pump export is not equivalent to a full RMAN physical database back-up.

  1. Physical database backup versus logical database export

This is a central topic in comparing RMAN and Data Pump.

RMAN

Undertakes physical database data backup.

It can then facilitate recovery of database and database components.

Data Pump

Transfers database data and objects to a logical export format.

Import subsequently re-creates database objects and populates them with exported data.

Comparison

RMAN Data Pump

Primary function Physical database backup/ recovery Logical database export/import

Interacts with Oracle database datafiles Yes No

Can recover corrupt database datafiles Yes No

Can export particular schemas Utilising diverse permitted recovery processes Yes

Can export particular tables No (through standard backup file selection) Yes

Supports database disaster recovery Yes (as part of an overall recovery strategy) Not a substitute for physical recovery

Enables logical database transfer Limited to permitted RMAN recovery processes Yes

Makes use of redo for media recovery Yes No

Output type Backup sets or image copies Dump file sets

Example

Assume that a database holds details of customers, together with transactional and application data.

Following misfortune, one or more Oracle database datafiles may become inaccessible. RMAN may then restore and Recover

These datafiles utilising redo information.

Conversely, if a specific application schema is to be relocated to a test database, Data Pump might prove to be the more easily utilised option.

The correct tool will depend on the aim.

  1. Understanding RMAN full and incremental database backups

RMAN can back up a database either as a full or incremental backup.

Full

Database datafiles or database datafile blocks are backed up according to the chosen type of full backup.

For instance:

 BACKUP DATABASE; 

Note: This is not standard SQL syntax.

Level 0 incremental

This forms a reference for subsequent incremental database backups.

 BACKUP INCREMENTAL LEVEL 0 DATABASE; 

A level 0 incremental will comprise blocks that are relevant for the reference. It can then act as the parent for further level 1 incrementals.

Level 1 incremental

Blocks modified since the relevant parent backup (depending on whether the incremental is differential or cumulative) are backed up.

 BACKUP INCREMENTAL LEVEL 1 DATABASE; 

Important note:

Whilst both a standard RMAN full database backup and a level 0 incremental can in some instances hold comparable data, only the latter can act as a parent for incremental backups. A level 1 is not an independent, full database backup.

Archived redo logs

These are significant for enabling transactional recovery beyond the point-in-time identified by a database datafile's checkpoint.

Typically, within a suitably configured ARCHIVELOG database, the following command may be issued:

 BACKUP DATABASE PLUS ARCHIVELOG; 

Suitable files and a valid recovery strategy are fundamental for successfully recovering from a backup.

Please note that the above command actually executes a database back-up. It should therefore only be executed within a permitted laboratory or live environment and with sufficient storage capacity.

  1. Understanding Data Pump export types

A DBA can define the logical extent of a Data Pump export.

Table export

Exports nominated database tables.

Example:

 expdp lab_user@LABPDB \ TABLES=LAB_USER.TRAINING_ORDERS \ DIRECTORY=ACE_DP_DIR \ DUMPFILE=orders_export.dmp \ LOGFILE=orders_export.log 

(Note: It is assumed that the relevant account, table, service and directory privileges are already in place.)

Schema export

Exports supported database objects associated with a nominated schema.

Example:

 expdp lab_user@LABPDB \ SCHEMAS=LAB_USER \ DIRECTORY=ACE_DP_DIR \ DUMPFILE=lab_schema.dmp \ LOGFILE=lab_schema_export.log 

Full export

 expdp authorized_admin@LABPDB \ FULL=YES \ DIRECTORY=ACE_DP_DIR \ DUMPFILE=full_export.dmp \ LOGFILE=full_export.log 

Appropriate privileges are necessary and this export type will export supported logical database objects within the relevant database scope.

Note: However, a full Data Pump export is not a comprehensive alternative to backing up database datafiles, control files, archived redo logs and all Oracle internal database data.

Further to this, when connected to a PDB, only that PDB is exported and not automatically all PDBs within a CDB.

  1. Total database failure scenario

Imagine that a storage-related problem leads to unavailability of key Oracle database datafiles. Normal database functionality is thus compromised.

Can Data Pump be used to recover the whole database?

Although a Data Pump dump file could be utilised to re-generate exported application objects within an already running database environment, it is not able to directly recover lost database datafiles. Nor can it facilitate Oracle database recovery via media recovery.

Can RMAN be used to recover the database?

Indeed, RMAN is designed to facilitate such recovery.

Provided that suitable database backups, redo information and control file data are available and that appropriate recovery methodologies can be applied, RMAN can both restore and recover a database.

Basic recovery sequence

 Storage failure | v Assess database and backup availability | v Identify required RMAN backups | v Restore required database files | v Apply necessary recovery information | v Open database as permitted | v Verify application and data integrity 

Whilst the precise recovery actions will depend on the issue encountered, they should always adhere to a proven recovery methodology.

Typically, RMAN will constitute the principle means of recovering from total database failure.

  1. Incorrectly deleted table scenario

Now consider an alternative situation.

An application table has been erroneously deleted.

Which tool should be utilised?

This will depend on the circumstances of the event and the recovery resources at a DBA's disposal.

Option 1 – Oracle Flashback

Where possible and appropriate, Oracle Flashback functionality can often be utilised to comparatively straightforwardly effect recovery.

For example, if a table has been mistakenly dropped from a database with recycle-bin functionality enabled, it can usually be recovered via Flashback Drop. Other Flashback functionality may require further conditions to be met.

Option 2 – Data Pump import

Should the deleted table have been exported using a suitable Data Pump export, it could then be imported into an appropriate environment. However, the data will correspond to that captured within the export and may not represent the last committed state of data prior to the table being deleted.

Option 3 – RMAN recovery

RMAN offers advanced database recovery functionality including specific table recovery and point-in-time recovery methods. Feasibility will be affected by factors such as database backups, access to redo information, database configuration and recovery aims.

Which is best?

Generally speaking, there is no single definitive response.

A DBA should ascertain:

What has been deleted.

When this occurred.

Whether Oracle Flashback is available.

Whether a suitable Data Pump export has been performed.

Whether a suitable RMAN recovery point exists.

What levels of data and service interruption can be tolerated.

Although importing via Data Pump can sometimes prove a convenient way of recovering a singular table, this should not be automatically adopted without due consideration of recovery consistency and inter-dependencies.

  1. Laboratory – Verifying RMAN database backups

Below is a laboratory which demonstrates various RMAN verification methods.

Environment: Authorised Oracle Database 19c test database.

Step 1 – Determine database archiving mode

Login to an authorised SQL session:

 SELECT name, log_mode, open_mode FROM v$database; 

This will show if the database is running in ARCHIVELOG or NOARCHIVELOG mode.

This is significant as it influences the range of recovery options that are available.

Step 2 – Launch RMAN

On a correctly configured database server:

 rman target / 

It is assumed here that the OS account has been authorised for local RMAN login.

Step 3 – View current backup listings

At the RMAN command line:

 LIST BACKUP SUMMARY; 

Summary information regarding existing backups is then displayed.

Step 4 – Assess backup needs

 RESTORE DATABASE PREVIEW; 

This aids in identifying which backups would be accessed for a database restore.

Step 5 – Confirm restorability

 RESTORE DATABASE VALIDATE; 

RMAN ascertains whether it can read the backup material that is necessary for a requested database restore, without itself writing database data files.

Significant I/O may occur during this process and so it should be undertaken at a suitable time, particularly within a multi-user environment.

What to document

Please detail within your laboratory report:

Database version and archiving mode.

RMAN's current backup listings.

Information provided by a restore assessment.

Verification outcomes.

Any warnings or failures.

Avoid including confidential or sensitive database and/or storage information.

Important caveat

Although beneficial, verification of a database backup is not a complete substitute for fully testing a database recovery within a dedicated test environment.

Alongside verifying database backups, a DBA must also evaluate other elements integral to a comprehensive database recovery strategy. These include relevant redo logs, control file information, encryption keys and database configuration, as well as application verification.

  1. Laboratory – Data Pump export and Import

This laboratory illustrates a repeatable method of exporting and importing data. Please do not utilise live customer data, credentials or confidential database tables.

Step 1 – Create a laboratory schema

Within a permitted PDB test database, first establish a basic table:

 CREATE TABLE training_orders ( order_id NUMBER PRIMARY KEY, amount NUMBER(10,2), order_status VARCHAR2(20) ); 

Next, insert a small amount of test data:

 INSERT ALL INTO training_orders VALUES (1,100,'PAID') INTO training_orders VALUES (2,250,'PENDING') INTO training_orders VALUES (3,500,'PAID') SELECT 1 FROM dual; COMMIT; 

Confirm how many rows are present:

 SELECT COUNT() AS total_orders FROM training_orders; 

Ideally, for the test data, this will return:

 TOTAL_ORDERS ------------ 3 

Note: Again, this is illustrative and not necessarily an actual outcome.

Step 2 – Create a Data Pump directory

Data Pump exports and imports data to and from an Oracle directory object, which in turn refers to a directory that is accessible to the database server. An administrator can view existing Oracle directory objects by executing:

 SELECT directory_name, directory_path FROM all_directories ORDER BY directory_name; 

For this laboratory exercise, suppose that an authorised administrator has already established a directory object named:

 ACE_DP_DIR 

Furthermore, the relevant OS directory must exist and possess the correct read and write permissions.

Step 3 – Export a laboratory schema

Employing an Oracle client with Data Pump installed, log in using an account that is authorised for laboratory schema export.

 expdp lab_user@LABPDB \ SCHEMAS=LAB_USER \ DIRECTORY=ACE_DP_DIR \ DUMPFILE=lab_user_export.dmp \ LOGFILE=lab_user_export.log \ FLASHBACK_TIME=SYSTIMESTAMP 

Here, LAB_USER is the name of the laboratory schema.

Securely input the database password when prompted; do not include it within publicly available commands or scripts.

The FLASHBACK_TIME parameter enables an export to logically represent the state of supported tables at a nominated point in time. Successful implementation will rely upon the database and undo data-retention settings.

Step 4 – Evaluate export results

Refer to the Data Pump export log to determine if the export completed successfully and whether any errors arose.

Ensure that a Data Pump dump file can be found on the database server or shared storage that Data Pump can access.

Bear in mind that a Data Pump export log does not definitively confirm that all nominated database objects were successfully exported. Thus, it should be examined.

Step 5 – Import into a dedicated target schema

Establish a fresh, empty target schema entitled LAB_USER_RESTORE.

Utilising an appropriately authorised Data Pump import account, the example below alters the source laboratory schema to be imported into the target schema:

 impdp authorized_admin@LABPDB \ DIRECTORY=ACE_DP_DIR \ DUMPFILE=lab_user_export.dmp \ LOGFILE=lab_user_import.log \ REMAP_SCHEMA=LAB_USER:LAB_USER_RESTORE 

Correct tablespace and quota settings must be in place for the target schema and the import account must have the right privileges.

Again, it is assumed that neither the source nor target schema names coincide with other existing objects.

Never conduct a database import within a live environment unless there has been approved change and a tested import methodology has been developed.

Step 6 – Confirm imported data

Post-import, execute:

 SELECT COUNT() AS restored_orders FROM lab_user_restore.training_orders; 

For the test data, ideally this will produce:

 RESTORED_ORDERS --------------- 3 

Compare this data with that of the source export.

To further validate the import, also check:

Structure of tables.

Number of rows.

Primary and foreign key constraints.

Indexes.

Permissions.

Stored procedures and other inter-linked objects.

Application functionality.

Equivalence in row count does not necessarily indicate that an entire and successfully conducted logical database recovery has taken place.

  1. Data Pump does not inherently offer continuous recovery

Consider a scenario whereby a schema is exported at 10.00am. Thereafter, further database transactions are executed.

At 4.00pm, a problem emerges.

Should a DBA import data based on the 10.00am export, generally this will represent a snapshot of database data at that time. However, it will not automatically encompass any transactions that had been committed after the export.

Hence it is evident that Data Pump exports should not be used in place of a well-designed RMAN and archived redo log backup strategy.

Where suitable database backups and redo information are available, RMAN can typically allow for more detailed recovery.

  1. Using RMAN and Data Pump for database transitions

Alongside backup and recovery, it is also common for DBAs to be involved in transitioning databases between different environments and/or Oracle versions.

Data Pump is especially well suited for facilitating logical database transitions.

For instance, a DBA may be required to transfer an application schema from an older, but still supported version of Oracle to Oracle Database 19c.

Generally, a Data Pump database transition will involve:

 Source database | v Check source version and compatibility | v Prepare target Oracle 19c database/PDB | v Export supported schema objects | v Transfer and secure dump files | v Import into target | v Validate objects, data, and application 

Oracle provides Data Pump import and export functionality for transitioning supported data between differing database versions. Nevertheless, it is important to investigate the compatibility and limitations in relation to the particular source and destination database versions.

Can RMAN directly import an older database backup into Oracle 19c?

No.

Unlike a Data Pump export, a physical database backup from an unspecified older Oracle version is not simply transferrable to a new Oracle 19c database. Some RMAN-based database transition and upgrade approaches are available, but each will have specific requirements and compatibility considerations.

The correct database transition approach will depend on the source and destination database versions, together with the relevant platform and architecture and the supported Oracle upgrade route.

  1. RMAN and Data Pump within banking

Within banking, where both data and database availability are of prime importance, a sound strategy should take into account both physical and logical aspects of recovery.

Physical recovery strategy

RMAN should feature within a thoroughly tested database back-up and recovery strategy. Key tasks are:

Ensuring that appropriate database back-up types are carried out.

Securing archive redo logs.

Monitoring the progress of database back-ups.

Verifying recoverability.

Protecting database back-up storage.

Testing database restoration and recovery.

Maintaining documentation of recovery processes.
Logical export

Logical export can be utilised to further enhance a physical recovery strategy.

Examples include:

Export application schemas.

Produce logical copies for authorised testing.

Enable targeted migration.

Ensure logical data is retained ahead of approved application updates.

Transfer supported objects between environments.

Security

Backups and exports can include confidential data.

Appropriate security, including encryption where necessary, should be applied to RMAN and Data Pump backups and exports. There should also be defined management of, and secure storage for, these items.

Whilst a database should be backed up, it is also essential that those carrying out recovery can access and utilise back-ups effectively.

Recovery Point and Time Objectives

Two vital aspects of a recovery strategy are:

Recovery Point Objective

The maximum period of data that can be lost.

Recovery Time Objective

The maximum period of time that a service can be disrupted.

For example, if a business states that:

RPO = 15 minutes

RTO = 2 hours

Then a recovery strategy should seek to ensure that no more than 15 minutes worth of data is lost and that the relevant service can be restored within 2 hours.

Please note that these are aspirational goals.

It is the responsibility of the DBA to confirm that the backup and recovery strategy can achieve these goals.

Typically, a daily Data Pump export would not meet a 15 minute RPO.

Depending on business needs, a combination of RMAN, archive redo log capability, high availability and/or a standby database, together with other techniques, could be suitable to achieve the desired outcome.

Common DBA errors

  1. Using EXPDP as a complete disaster recovery technique

EXPDP is a logical export facility.

It should not be used as an alternative to physical recovery.

  1. Believing that because an RMAN backup has been successfully run, it can always be used for recovery

Even if an RMAN backup completes successfully, this does not always ensure that full recovery can be achieved. Undertake suitable validation and recovery testing.

  1. Failing to confirm archive redo logs are available

Where it is necessary to recover data beyond the point-in-time of the last backup, archive redo logs can be crucial. The DBA needs to be aware of the backup and archive log management settings.

  1. Importing a dump without confirming suitability

During a Data Pump import, issues such as mismatched schema, database version, character set, permissions and/or functionality can prevent a successful import. Always analyse the particular migration requirements.

  1. Considering that because IMPDP was successfully run, the application is now in a fit state

Logical imports need to be validated. Assess data, objects, permissions and application operation.

  1. Conducting recovery tests within production

Generally, recovery testing should occur within a secure, dedicated test environment and under appropriate control. Within production, recovery tasks must be executed under an authorised incident or change management process.

Best practice for DBAs

An ideal Oracle DBA will utilise the correct technology for each task.

Physical recovery can be achieved using well-tested RMAN strategies and relevant supporting information.

For logical export and migration, Data Pump should be used ensuring that suitable validation, permissions and compatibility are in place.

Information should be recorded for both physical and logical recovery/migration, covering:

The recovery/migration goal.

Source and destination environments.

Oracle database versions.

Conditions/requirements.

Commands.

Outcomes.

Notes and constraints.

Validation steps.

Methods of rollback/recovery.

Above all, even if a good quality backup or export is achieved, it is vital to confirm that the relevant data and services can indeed be recovered in line with the business’ goals.

Conclusion

Both Oracle Recovery Manager and Data Pump are valuable tools for Oracle Database Administrators. However, they address distinct areas.

RMAN is used for physical Oracle database file backup and recovery.

Data Pump is used for logical export together with import and for migration of database objects and data.

Neither RMAN nor Data Pump should be chosen merely for their ability to generate a file which can be referred to as a backup.

The right option will depend on what is to be recovered, the acceptable level of data loss and the desired speed of service resumption together with the available recovery techniques.

For a DBA, key practice is to establish a robust physical recovery strategy using RMAN. Data Pump should then be used to enable logical data transfer and for some recovery situations. Both should be tested and their constraints analysed. Never consider that because a backup has been generated, recovery will automatically succeed.

Oracle Documentation

  1. Oracle Database 19c – Introduction to Backup and Recovery

https://docs.oracle.com/en/database/oracle/oracle-database/19/bradv/introduction-backup-recovery.html

  1. Oracle Database 19c – Getting Started with RMAN

https://docs.oracle.com/en/database/oracle/oracle-database/19/bradv/getting-started-rman.html

  1. Oracle Database 19c – Validating Database Files and Backups

https://docs.oracle.com/en/database/oracle/oracle-database/19/bradv/validating-database-files-backups.html

  1. Oracle Database 19c – Overview of Oracle Data Pump

https://docs.oracle.com/en/database/oracle/oracle-database/19/sutil/oracle-data-pump-overview.html

  1. Oracle Database 19c – Data Pump Export

https://docs.oracle.com/en/database/oracle/oracle-database/19/sutil/oracle-data-pump-export-utility.html

  1. Oracle Database 19c – Data Pump Import

https://docs.oracle.com/en/database/oracle/oracle-database/19/sutil/datapump-import-utility.html

  1. Oracle Database 19c – Performing Complete Database Recovery

https://docs.oracle.com/en/database/oracle/oracle-database/19/bradv/rman-complete-database-recovery.html