Recovery with Archiving  «Prev  Next»

Lesson 5 Performing Closed Database Recovery
Objective Demonstrate complete media recovery of a damaged CDB-root datafile while the database is mounted.

Performing Closed Database Recovery in Oracle AI Database 26ai

Suppose a storage failure damages a datafile belonging to the SYSTEM tablespace in the root of a multitenant container database, or CDB. The current control file and online redo logs survive, and a usable backup of the damaged file exists. Your task is to restore that file, apply the necessary recovery information, and return the database to service.

This is a closed database recovery scenario. The database remains mounted, rather than open, while media recovery repairs the restored file. The instance is running during recovery: it must read the control file, coordinate recovery, and apply changes to the datafiles.

Closed recovery describes the database state, not the number of files you must restore. If one datafile is damaged, complete recovery can restore and recover that file while preserving the good current files. Restoring the whole database would expand the work unnecessarily in this example.

The two walkthroughs below demonstrate the same recovery objective. RMAN coordinates restoration and recovery using its backup repository. The SQL*Plus alternative assumes that a valid physical backup copy is restored separately with an operating-system utility. Select the method appropriate to your backup format and recovery procedure.

Establish the Recovery Conditions

The examples assume a single-instance primary CDB in ARCHIVELOG mode, a usable current control file and startup configuration, and sufficient backups and recovery information. Required redo may include both archived logs and changes still present in surviving online logs. ARCHIVELOG mode alone does not guarantee that every required log remains available.

Connect to CDB$ROOT with suitable administrative privileges. The local connection examples assume operating-system authentication is configured and the environment identifies the correct Oracle installation and target instance. If backup media or data is encrypted, make the necessary keys, keystores, or backup passwords available as required.

The affected file in this lesson is a CDB-root SYSTEM datafile. A PDB's SYSTEM or local undo failure requires assessment of that PDB's recovery scope; it does not automatically require this same whole-CDB outage. RAC, standby recovery, and point-in-time recovery also have additional requirements.

Database State During the Worked Recovery
State Meaning for this procedure
Instance stopped The user-managed example copies the backup file into place while Oracle is stopped.
Database mounted The instance has opened the control file. RMAN can restore the affected datafile, and media recovery can run.
Database open Recovery has satisfied the requirements for opening. Verify intended PDBs, services, and application access.

Diagnose the Failure Before Restoring

Read the alert log and operating-system errors, identify the failed storage, and determine whether the data is damaged or temporarily inaccessible. A repaired access problem with intact files may require restarting the database and automatic instance recovery, without restoring an older file.

When a privileged SQL*Plus session can access the mounted or open database, inspect recorded recovery requirements:

SELECT file#, error, online_status, change#, time
FROM v$recover_file;

Map the reported file number to its current name and container:

SELECT con_id, file#, name, status
FROM v$datafile
ORDER BY con_id, file#;

The recovery-view column is ONLINE_STATUS; STATUS belongs to the separate V$DATAFILE query. These queries avoid confusing the two views. If you extend the diagnosis with tablespace joins, include container identity because tablespace numbers are local to their containers.

For this example, diagnosis confirms that file number 1 identifies the damaged root SYSTEM datafile, recorded as /u02/oradata/CDB1/system01.dbf. Verify actual metadata before substituting these illustrative values. If the instance is stopped, obtain the diagnostic results after mounting at the appropriate step below.

V$RECOVER_FILE can be unreliable after restoration or re-creation of a control file. Even with the current control file, combine its results with the alert log and appropriate datafile-header or integrity checks. An empty result does not establish that every data block is healthy.

Prepare the Instance and Storage

If the database remains open and can shut down normally, use SQL*Plus to perform an orderly shutdown:

SHUTDOWN IMMEDIATE

The failure may already have stopped the instance. Check its state rather than issuing shutdown commands mechanically. An unresponsive instance may require SHUTDOWN ABORT under the incident procedure, but neither an abort shutdown nor STARTUP FORCE is the default recovery step.

Repair or replace the failed storage, confirm adequate capacity and permissions, and preserve the surviving control files and online redo. Establish that the selected backup belongs to the intended database and supports the required recovery path. Backup metadata, encryption access, and functioning media-management software may all matter.

RMAN can preview restore selection and validate backup readability when those checks are appropriate. A preview uses repository information; restore validation reads backup contents without restoring the datafile. Choose checks that address the incident rather than assuming a listed backup is readable.

Preferred Method: Closed Recovery with RMAN

Use RMAN for RMAN backup sets and for restoration workflows it manages. At the operating-system prompt, establish the configured local administrative connection:

rman target /

The following stages assume the instance is stopped, file 1 is the only file requiring restoration and recovery, and its original destination is usable. If you already mounted the database for diagnosis, continue from the restore stage. Use a session without a point-in-time restriction such as SET UNTIL.

1. Mount the Database

STARTUP MOUNT;

Mounting makes the current control file available without opening the database for normal use. Confirm the target and affected file before proceeding. Do not attempt an ordinary startup that opens the database before the damaged SYSTEM file is recovered.

2. Restore the Damaged File

RESTORE DATAFILE 1;

RMAN selects and restores a suitable backup of this datafile using the available repository and backup access. The restored file contains an earlier state. Successful restoration establishes that a file copy has been retrieved, not that the database can now open.

If the original destination is unavailable, use a separately planned relocation workflow, such as RMAN SET NEWNAME and SWITCH, to restore elsewhere and update the recorded location. The simple command above assumes no relocation is necessary.

3. Recover the Restored File

RECOVER DATAFILE 1;

Recovery advances the restored file using the required recovery information. RMAN can use applicable incremental backups and restore required archived redo from accessible backups. Surviving online redo may provide the latest required changes.

Review the output and resolve errors before proceeding. If RMAN cannot access a required backup or log, repair that access or locate another usable recovery path. Do not interpret the end of available files in one directory as successful complete recovery.

4. Open After Successful Complete Recovery

ALTER DATABASE OPEN;

This example uses the current control file and performs complete recovery, so it opens normally. RESETLOGS is not a substitute for applying missing recovery information. Recovery with a backup control file and deliberate database point-in-time recovery have separate opening requirements.

Execute each stage only after the preceding stage succeeds. If opening reports another file requiring recovery, reassess the diagnosed scope and address that file; do not change the opening command simply to bypass the error. Oracle's RMAN complete recovery guide covers additional recovery scopes.

Alternative Method: User-Managed Recovery with SQL*Plus

This is an alternative walkthrough for the same failure, beginning with the instance stopped and storage repaired. It requires a valid physical backup copy of the datafile. SQL*Plus RECOVER applies redo; it does not extract a datafile from an RMAN backup set.

Restore the Physical File Copy

For a conventional filesystem, an operating-system copy might be:

cp /backup/CDB1/system01.dbf /u02/oradata/CDB1/system01.dbf

The source must be a usable physical backup made with a valid backup procedure. An arbitrary copy of a file while the database was open is not sufficient. Confirm the source, destination, copy completion, and Oracle's access permissions. This command is not an ASM restoration procedure.

The example restores to the recorded location. If you instead copy to another filesystem location, update the control file while mounted with the appropriate ALTER DATABASE RENAME FILE statement. That statement changes the recorded name; it does not move the bytes.

Mount and Check File Status

Connect through SQL*Plus using the configured local administrative account:

sqlplus / as sysdba

Then mount the database:

STARTUP MOUNT

Use the diagnostic queries to verify file number, filename, container, and status. For database-scope SQL*Plus recovery, eligible files needing recovery must be online while the database remains mounted. File ONLINE status does not mean the database is OPEN.

Where the chosen procedure requires bringing the identified file online, the statement is:

ALTER DATABASE DATAFILE 1 ONLINE;

Do not apply this blindly to every file. Preserve intentional offline and read-only states where appropriate. A file already online does not need its status changed merely because its restored contents require media recovery.

Apply Redo and Open

RECOVER AUTOMATIC DATAFILE 1

AUTOMATIC lets SQL*Plus select expected archived-log filenames. Without it, an interactive recovery prompt can accept AUTO to continue automatic selection. These SQL*Plus controls are distinct from RMAN's command syntax and backup-restoration capabilities.

Recovery must apply the required archived and online redo and report successful completion. SQL*Plus can report:

Media recovery complete.

After checking completion and the affected scope, open normally:

ALTER DATABASE OPEN;

Database-scope RECOVER is also available for an appropriate set of files requiring recovery, but this example deliberately names one identified file. See Oracle's user-managed recovery procedures for the broader mounted-database workflow.

Handle Alternate Log Locations and Missing Redo

If archived logs were restored to a staging directory, SQL*Plus can use that directory as its log source:

SET LOGSOURCE /restore/archivelogs
RECOVER AUTOMATIC DATAFILE 1

An alternative is to specify FROM in the recovery command:

RECOVER AUTOMATIC FROM '/restore/archivelogs' DATAFILE 1

Use these as separate alternatives. The SQL*Plus FROM clause cannot be combined with SET LOGSOURCE. Pointing recovery at existing logs does not change where the database archives newly filled online logs. The SQL*Plus RECOVER reference describes these options.

V$ARCHIVED_LOG records archived-log metadata; V$RECOVERY_LOG can help identify media-recovery log requirements. Neither proves a required file is physically readable. Match the recovery request to the correct thread, sequence, and incarnation, especially when several copies or historical logs exist.

AUTOMATIC does not retrieve a missing backup. Restore the required log through the appropriate tool, or supply a correct full filename when needed. Preserve surviving online redo because the last required changes may not yet exist in archived logs.

If required redo is unavailable, investigate other copies, backups, and usable incremental recovery paths. A permanently unresolved gap means the complete-recovery objective needs reassessment. Choosing an earlier endpoint involves its own restoration scope, consistency requirements, and possible data loss. It is not an automatic response to one missing-file message.

Worked Scenario: The Backup Restores but Recovery Stops

Assume the usable backup of the root SYSTEM datafile was taken overnight. The storage failure occurs the following afternoon. Other current datafiles remain intact, and the surviving online redo logs contain the latest redo. Restoring the overnight file succeeds, but the restored file still needs intervening changes before it can participate in the current database.

Recovery then requests an archived log that is absent from its original destination. The DBA finds that a scheduled job backed up that log before removing its disk copy. The problem is locating and retrieving the required recovery input, rather than immediately selecting an earlier database state.

With RMAN, an accessible log backup known to the repository can be restored as recovery proceeds. With user-managed recovery, the DBA retrieves the log through the appropriate restoration procedure and makes it available to SQL*Plus. In either case, the next decision follows the actual recovery request and the available backup evidence.

After the gap is resolved, recovery continues through the required redo, including surviving online redo when necessary. The good current datafiles do not need to be replaced just because the restored SYSTEM file came from an older backup. Recovery advances the affected file until the database can satisfy its opening requirements.

If the log has no usable copy and no alternative recovery path supplies the missing changes, the original complete-recovery plan remains unfinished. The DBA must evaluate recovery options for a consistent affected scope. Simply canceling recovery and trying RESETLOGS does not make the existing mixture of file states suitable for a chosen earlier endpoint.

Oracle AI Engineering

Verify the Database and Application

After opening the CDB, inspect its mode and the states of its PDBs:

SELECT open_mode FROM v$database;

SELECT name, open_mode
FROM v$pdbs
ORDER BY name;

Open intended application PDBs only when needed. For example, if the application's SALES PDB remains mounted and should be available:

ALTER PLUGGABLE DATABASE sales OPEN;

The PDB name is illustrative. Saved state can restore a PDB's open mode when the CDB restarts, so explicit opening is not always necessary. Preserve intended read-only or closed states. Oracle documents this behavior in ALTER PLUGGABLE DATABASE.

Review the alert log, check affected files, and verify that intended services accept connections. Where warranted, use scoped integrity checks such as RMAN validation. Block-level validation does not establish that application transactions or business records have the expected meaning.

Complete recovery preserves committed changes when their required recovery information is available. Uncommitted work is rolled back. If a user lost the connection around a commit, verify the transaction's outcome before retrying: resubmitting a transaction that actually committed can create duplicate business operations.

Successful opening means the recovered files meet the consistency requirements for opening. It does not require identical header SCNs for every read-only or intentionally offline file, nor does it prove that every application service has resumed.

Protect the Recovered Database

Resume scheduled backups and decide whether additional protection is needed after the incident. Account for replaced storage, relocated files, available recovery points, and the organization's recovery objectives. Confirm that backup jobs can still reach their destinations and use the required keys and credentials.

Remove staged archived logs only after confirming that required retained copies remain available and that deletion follows the applicable policy. Avoid broad wildcard deletion from shared temporary directories. Record the restored file, backup source, recovery outcome, and any service restrictions that remain.

Keep the recovery record specific enough for another DBA to understand the result. Include the target database, container and file identity, original and final filenames, backup identifiers, errors encountered, and the checks used to confirm service. Document any log copies restored to temporary locations so that later cleanup distinguishes recovery staging from retained backup material.

Use the incident to improve the next recovery attempt. A backup that was readable but difficult to locate may indicate missing runbook details. Repeated media-access failures may justify testing that access during scheduled recovery rehearsals. Update the operational procedure to reflect the recovery that actually succeeded.

The essential order is diagnosis and preparation, restoration of the affected file, complete media recovery while mounted, normal opening with the current control file, and verification of database and application service.


SEMrush Software 5 SEMrush Banner 5