A failed nightly restore should cost developers a day of freshness. Rebuilding the only development clone can cost them the environment itself. I wrote Kogarasu-Maru for an Oracle 12.2 environment with two clone slots on disaster recovery infrastructure. While RMAN rebuilt one slot, the other could keep serving developers. The script picked the slot to rebuild using an application data marker and restored only the tablespaces the development environment needed.
The recovered Bash script documents how this worked, including where the safety checks ended. The examples below use invented names. The original implementation used Clusterware, ASM and a recovery catalog. The proposed handoff and 19c command example are for a new implementation.
Kogarasu-Maru Bash script · Archive README and example configuration
Choose a clone using data freshness
The job took a pair of candidate databases from its configuration. In automatic mode, get_sidlist looked for their local SMON processes and used Clusterware to try to bring up a missing member. Then get_targetdb preferred a slot that still failed to appear. If both appeared, get_maxinttid opened a local SQL*Plus session on each and read the maximum ID from an application transaction table. The smaller maximum identified the older data, so that slot was selected for replacement.
| Observation | What the original job did |
|---|---|
| One configured clone failed the startup probe | Selected that slot for replacement. |
| Both clones answered the application query | Replaced the clone with the lower transaction ID. |
| A SQL probe returned a non-numeric result | Treated it as zero, which made that clone a candidate for replacement. |
| Both markers were equal | Kept the first candidate encountered by the strict less-than comparison. |
The marker mattered because a database startup time tells you when the instance started. The application marker tells you something about the data developers can actually see. It works when the marker advances with source data, the same object is readable in both clones, and developers’ own writes cannot make an older snapshot look newer. This was an application-specific proxy for freshness.
For a new controller, I would separate the result of the probe from the marker itself. A failed query becomes UNKNOWN. It can mean the database is closed, a view was invalidated, or the database name resolved to the wrong service. Resolve the live developer service independently. Select a replacement only after proving which slot is serving and which slot is eligible for a rebuild. If the observations disagree, stop before cleanup.
Pick an SCN and build the duplicate command
The recovered get_targetscn function queried the catalog’s underlying log-history tables for the highest starting SCN in a time window for the source database’s current incarnation. Its result still lived in a variable named TARGETSEQUENCE after the script switched to SCN-based recovery. The file also preserves an emergency override that picked a window six to ten days back. That detail matters when investigating a successful refresh with unexpected data age.
An SCN gives the whole database a common recovery boundary, including when a RAC source has several redo threads. The catalog query selected a candidate boundary. An archived-log record alone does not establish that the matching piece is present and readable at the restore host. Use documented catalog views such as RC_ARCHIVED_LOG when examining the incarnation and thread ranges, and RMAN’s backup inventory and validation to verify the restore inputs. Check the required datafile and control-file backups, plus the archived redo needed from those backups up to the boundary across the required threads. Record the selected SCN and the reason for choosing it. UNTIL SCN is an upper, non-inclusive boundary.
The historical script connected to the recovery catalog and to the local auxiliary. It generated a DUPLICATE DATABASE … DBID … TO … UNTIL SCN command, explicitly allocated auxiliary disk channels, and supplied an exclusion list. It generated Oracle parameters for ASM-backed data and recovery areas and prepared the clone for single-instance duplication. Afterward the site used Clusterware to manage the clone. This was an independent duplicate with its own DBID. A physical Data Guard standby shares the primary’s DBID and continues to apply primary redo.
Here is the shape of the command for a 19c non-CDB lab. Start the intended auxiliary in NOMOUNT with its own default SPFILE and isolated file destinations. Use a catalog connection and an auxiliary connection, and make the source backup pieces accessible to the auxiliary at their cataloged paths. The two auxiliary channels below are an example. The source name, DBID, SCN and tablespace are lab inputs.
RUN {
ALLOCATE AUXILIARY CHANNEL a1 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL a2 DEVICE TYPE DISK;
DUPLICATE DATABASE PROD DBID 3984712051 TO DEV_B
UNTIL SCN 48210000
SKIP TABLESPACE HISTORY_ARCHIVE
SKIP READONLY
NOOPEN;
RELEASE CHANNEL a1;
RELEASE CHANNEL a2;
}NOOPEN keeps the duplicate mounted so I can check its identity and file placement before the controlled OPEN RESETLOGS in the isolated lab. Define the auxiliary’s OMF destinations ahead of time, including data, control and redo placement. Verify the resulting paths before opening. If the source uses OMF, use supported OMF naming options for the duplicate. Avoid copying the filename substitutions from the old script into an unrelated storage layout.
The original also edited the recovery catalog’s stored device configuration to reduce parallelism on its restore storage, then tried to restore the normal setting. I would use per-run auxiliary channels for a new job. That keeps a paused or interrupted clone restore from leaving a shared catalog setting changed. Measure elapsed restore time and backup-storage throughput as you adjust channel count. More channels can move the bottleneck to the backup store.
Oracle 19c RMAN DUPLICATE · RMAN recovery boundaries · Recovery catalog archived-log records
A partial clone needs an application contract
Kogarasu-Maru deliberately omitted configured historical tablespaces and read-only content. The saved code shows the consequence for a partitioned transaction table. A post-restore routine renamed the physical table, inspected partition metadata to find a retained range, and recreated the application-facing name as a view restricted to retained IDs. It then attempted to recompile invalid objects and restarted the clone through Clusterware.
That changed what the clone could answer. When using the same pattern, document which history is missing and which application reads the clone supports. Check that the selected tablespaces form a valid RMAN exclusion set. Then test the application at the boundary, with one query in the retained range and one that would otherwise visit excluded data. Include affected views, grants and dependent SQL in the check. A query against an unrelated lookup table tells you very little about whether a selective clone is fit for use.
Keep the old clone until the new one passes
The recovered script checked for a nonzero application marker after duplicate. On success it stopped the counterpart and then ran the view changes, object recompilation and service-registration work. That ordering is the practical weakness of the old handoff. A positive marker showed that one query worked. A failure during the remaining startup or application work could still leave developers without either usable endpoint.
For a new implementation I would keep the two slots and put the following checks before the developer service moves.
- Fence the candidate. Take a job lock, resolve the live service, and verify that the candidate is the inactive slot. Check the candidate identity and compare the resolved Oracle and ASM destinations against the serving slot and source. Grant cleanup access only to the candidate’s own paths. Keep developer traffic and outbound application integrations away from the candidate before it opens.
- Verify the restore and clone preparation. Require a successful RMAN exit status and retain the generated command and log. Check
NAME,DB_UNIQUE_NAME,DBID,DATABASE_ROLEandOPEN_MODEfromV$DATABASE. In a CDB deployment, check the intended PDBs too. Complete isolation, masking and application repair before allowing general developer connections. - Run an application-level probe. Use a candidate-only connection to verify the expected data marker, a known included record, and the behavior at the history boundary. Check the clone’s freshness against the selected recovery point. Treat query errors as validation failures.
- Move the service and verify it from a client. Record the intended target before moving the service. Then connect through the usual developer endpoint in a new session and check the destination and a known data marker. Existing sessions can remain attached to the old clone until they drain. If the process stops during the handoff, resolve the actual service mapping before any retry. Keep the prior clone available until the acceptance window closes.
In the legacy script, test mode bypassed the main drop-and-duplicate block but still reached catalog configuration changes and the status-based post-restore branch. I would give a new job a separate planning mode that only prints the selected slot, recovery boundary and proposed paths. The plan should be inspectable without credentials capable of changing the catalog or stopping a clone.
Rehearse the failure and record the result
In an isolated lab, interrupt the candidate restore after it starts writing files. Connect through the normal developer endpoint and confirm it still returns the previous clone’s marker. Next, complete a restore and make the application probe fail. Verify the service stays on the old slot. Finally, let the candidate pass and confirm a new connection reaches it. Record the selected and serving slots, source and clone DBIDs, boundary SCN, elapsed restore time, and marker seen at each step.
That is how I would test the reason for using two slots in the first place. A failed refresh should leave a known snapshot available, with its age visible to the people still using it.