top of page

Building a Test Copy in Another Cloud with RMAN Active Duplicate

OmerNarman
Nov 1
8 min read

Test teams want a copy of production, and they want it where their applications run. When production is in OCI and the test environment is in Azure, the usual route, a backup copied across clouds and restored on the other side, needs staging space at both ends and a lot of waiting. RMAN active duplicate skips the staging: the auxiliary instance pulls the data files straight from the running source over Oracle Net and builds a new, independent database.


This post builds a test copy of a 19c production database from an OCI VM onto an Azure VM, then makes that copy safe to use: new DBID, no scheduled jobs, no links pointing back at production. The source stays open throughout.



The Use Case

A test team in Azure needs a fresh copy of the SALES production database every month, under a new name, on a VM next to their test application servers. Copying backups between clouds has taken a whole day. The copy must never be able to send mail, run jobs or connect back to production.


Environment used in this runbook


  • Source: SALES, Oracle Database 19c (19.24) non-CDB on an OCI VM, host sales-oci-db1, 1.2 TB, open read write

  • Target: SALESTST on an Azure VM, host salestst-az-db1, same 19c home and patch level, ASM disk group +DATA

  • Network: private interconnect between OCI and Azure, Oracle Net on TCP port 1521 in both directions

  • Licence: RMAN duplication is part of every Oracle Database edition; BASIC compression needs no extra option



How Active Duplicate Works

  • The auxiliary instance pulls the data. With the USING BACKUPSET clause (the default method since 12c), the auxiliary instance connects to the source and RMAN creates backup sets on the fly that travel over the network, so nothing is written to disk at the source.

  • Section size splits large files. Each data file is divided into sections that several channels copy in parallel, so one huge data file does not become the bottleneck.

  • A new database is born. At the end, RMAN recovers the copy, opens it with RESETLOGS and gives it a new DBID, so it is completely independent of production and of its backups.



Step 1: Check the Source

Duplicate needs a source in ARCHIVELOG mode when it is open during the copy, because the archived redo generated while the copy runs is used to make the copy consistent. Record the size and the parameters you will override on the target.


SQL

-- On the source SALES

SELECT name, log_mode, open_mode FROM v$database;

SELECT ROUND(SUM(bytes)/1024/1024/1024) AS datafile_gb FROM v$datafile;

SELECT name, value FROM v$parameter

WHERE name IN ('db_create_file_dest', 'sga_target', 'job_queue_processes');

Expected output

NAME      LOG_MODE     OPEN_MODE
--------- ------------ --------------------
SALES     ARCHIVELOG   READ WRITE

DATAFILE_GB
-----------
       1211

NAME                           VALUE
------------------------------ ------------------------------
db_create_file_dest            +DATA
job_queue_processes            80
sga_target                     64G

What to expect: ARCHIVELOG, open read write, 1.2 TB of data files, Oracle Managed Files in +DATA, a 64 GB SGA and 80 job queue processes. The test VM is smaller, so the SGA must be reduced, and jobs must be disabled on the copy before it ever opens.



Step 2: Create the Password File and Parameter File on the Target

The auxiliary instance needs a password file with the same SYS password as the source, so RMAN can authenticate both connections. Copy the source's password file rather than creating a new one. Then write a minimal parameter file: RMAN copies the source's spfile and applies the overrides you give it.


Shell

# On the target host, as oracle

scp oracle@sales-oci-db1:$ORACLE_HOME/dbs/orapwSALES $ORACLE_HOME/dbs/orapwSALESTST

cat > $ORACLE_HOME/dbs/initSALESTST.ora <<'EOF'

db_name=SALESTST

EOF

export ORACLE_SID=SALESTST

sqlplus -s / as sysdba <<'EOF'

STARTUP NOMOUNT

SELECT instance_name, status FROM v$instance;

EOF

Expected output

ORACLE instance started.

INSTANCE_NAME    STATUS
---------------- ------------
SALESTST         STARTED

What to expect: An instance started in NOMOUNT with almost no parameters. That is all RMAN needs to begin. If the source keeps its password file in ASM, extract it first with asmcmd pwcopy on the source host.



Step 3: Register a Static Service for the Auxiliary Instance

RMAN restarts the auxiliary instance during the duplicate. An instance in NOMOUNT does not register itself dynamically with the listener, so add a static entry to listener.ora on the target and reload the listener.


Shell

cat >> $ORACLE_HOME/network/admin/listener.ora <<'EOF'

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = SALESTST)

(ORACLE_HOME = /u01/app/oracle/product/19.0.0/dbhome_1)

(SID_NAME = SALESTST)))

EOF

lsnrctl reload

lsnrctl status | grep -A1 SALESTST

Expected output

The command completed successfully
Service "SALESTST" has 1 instance(s).
  Instance "SALESTST", status UNKNOWN, has 1 handler(s) for this service...

What to expect: The SALESTST service with status UNKNOWN, which is how a static registration shows. If the target uses a Grid Infrastructure listener, add the entry to the listener.ora in the Grid home instead and reload that listener.



Step 4: Check Oracle Net in Both Directions

The duplicate opens two connections: RMAN on the target connects to the source as TARGET, and the auxiliary instance connects to the source to pull the backup sets. Test both with SQL*Plus before starting a long run. Add SALES and SALESTST entries to tnsnames.ora on the target host.


Shell

# On the target host

sqlplus -L sys@SALES as sysdba <<'EOF'

SELECT name, open_mode FROM v$database;

EOF

sqlplus -L sys@SALESTST as sysdba <<'EOF'

SELECT instance_name, status FROM v$instance;

EOF

Expected output

NAME      OPEN_MODE
--------- --------------------
SALES     READ WRITE

INSTANCE_NAME    STATUS
---------------- ------------
SALESTST         STARTED

What to expect: Both connections succeed with the SYS password. ORA-01017 means the password files differ; ORA-12514 on SALESTST means the static listener entry is missing. Because production data will cross the interconnect, make sure Oracle Net traffic between the hosts is encrypted (see the native network encryption post on this blog).



Step 5: Run the Active Duplicate

Connect RMAN to both databases from the target host and run the duplicate. The SPFILE clause copies the source's spfile and applies the overrides; SET clauses adjust everything the test copy must not inherit.


Shell

rman target sys@SALES auxiliary sys@SALESTST <<'EOF'

RUN {

ALLOCATE CHANNEL c1 DEVICE TYPE DISK;

ALLOCATE CHANNEL c2 DEVICE TYPE DISK;

ALLOCATE CHANNEL c3 DEVICE TYPE DISK;

ALLOCATE CHANNEL c4 DEVICE TYPE DISK;

ALLOCATE AUXILIARY CHANNEL a1 DEVICE TYPE DISK;

ALLOCATE AUXILIARY CHANNEL a2 DEVICE TYPE DISK;

ALLOCATE AUXILIARY CHANNEL a3 DEVICE TYPE DISK;

ALLOCATE AUXILIARY CHANNEL a4 DEVICE TYPE DISK;

DUPLICATE TARGET DATABASE TO SALESTST

FROM ACTIVE DATABASE

USING COMPRESSED BACKUPSET

SECTION SIZE 32G

SPFILE

SET db_unique_name = 'SALESTST'

SET db_create_file_dest = '+DATA'

SET db_recovery_file_dest = '+DATA'

SET sga_target = '16G'

SET pga_aggregate_target = '4G'

SET job_queue_processes = '0'

SET log_archive_dest_2 = ''

SET fal_server = ''

NOFILENAMECHECK;

}

EOF

Expected output

Starting Duplicate Db at 01-NOV-26
...
contents of Memory Script:
{
   restore clone from service  'SALES' using compressed backupset
   section size 32 G spfile to  '/u01/app/oracle/product/19.0.0/dbhome_1/dbs/spfileSALESTST.ora';
   sql clone "alter system set spfile= ''/u01/app/oracle/product/19.0.0/dbhome_1/dbs/spfileSALESTST.ora''";
}
...
channel a1: restoring section 1 of 12
channel a2: restoring section 2 of 12
...
Executing: alter database open resetlogs
database opened
...
Finished Duplicate Db at 01-NOV-26

What this does: Four channels on each side copy the data files in 32 GB sections, compressed with the BASIC algorithm on the way. The overrides give the copy its own name and storage, a smaller memory footprint, no job queue processes, and no redo shipping to production's standby. At the end RMAN recovers with the archived redo created during the copy, opens with RESETLOGS and assigns a new DBID. Over a 10 Gbit/s interconnect, 1.2 TB typically takes two to three hours.


Tip: If the copy must be from a point in time, not the latest state, add UNTIL TIME or UNTIL SCN to the DUPLICATE command. RMAN then recovers the copy only to that point.


Step 6: Confirm the Copy Is Independent

The copy must have its own identity. A new DBID guarantees that its backups never mix with production's in an RMAN catalogue, and that tools which key on the DBID treat it as a different database.


SQL

-- On the target SALESTST

SELECT dbid, name, db_unique_name, open_mode, database_role FROM v$database;

SELECT value FROM v$parameter WHERE name = 'job_queue_processes';

Expected output

      DBID NAME      DB_UNIQUE_NAME   OPEN_MODE            DATABASE_ROLE
---------- --------- ---------------- -------------------- ----------------
1879043256 SALESTST  SALESTST         READ WRITE           PRIMARY

VALUE
------------------------------
0

What to expect: A DBID different from production's, the new name SALESTST, open READ WRITE as its own primary, and job_queue_processes 0. Compare the DBID with the same query on SALES to be certain. If you duplicate a standby instead (FOR STANDBY), the DBID stays the same, which is right for a standby and wrong for a test copy.



Step 7: Neutralise Anything That Points at Production

A copy carries production's database links, scheduler jobs, directory paths and mail settings. Find them before anyone turns jobs back on.


SQL

COLUMN owner FORMAT A10

COLUMN db_link FORMAT A20

COLUMN host FORMAT A28

SELECT owner, db_link, host FROM dba_db_links ORDER BY owner, db_link;

SELECT owner, job_name, enabled

FROM dba_scheduler_jobs

WHERE enabled = 'TRUE' AND owner NOT IN ('SYS', 'ORACLE_OCM', 'EXFSYS')

ORDER BY owner, job_name;

Expected output

OWNER      DB_LINK              HOST
---------- -------------------- ----------------------------
SALES      ERP_PROD             erp-prod-scan:1521/erp_app
SALES      HR_PROD              hr-prod-db:1521/hr_app

OWNER      JOB_NAME                       ENABL
---------- ------------------------------ -----
SALES      NIGHTLY_INVOICE_MAIL           TRUE
SALES      SYNC_TO_ERP                    TRUE

What to expect: Two links to production systems and two application jobs that send mail and push data to ERP. Drop or repoint the links to test systems, and disable the jobs (DBMS_SCHEDULER.DISABLE) before setting job_queue_processes back to a normal value. Also check UTL_SMTP or UTL_MAIL settings and any directory objects that point at shared production file systems.



Step 8: Secure and Mask the Copy

A test copy of production is still production data. Change the passwords of privileged and application accounts, and mask personal data before testers get access. Oracle Data Masking and Subsetting is an extra-cost pack; a scripted UPDATE of the sensitive columns is the minimum alternative.


SQL

ALTER USER system IDENTIFIED BY "TestSystem#2026";

ALTER USER sales IDENTIFIED BY "TestSales#2026";

-- Minimum masking: overwrite personal data in place

UPDATE sales.customers

SET email = 'cust' || customer_id || '@example.invalid',

phone = NULL,

birth_date = DATE '1980-01-01';

COMMIT;

SELECT COUNT(*) AS unmasked_emails

FROM sales.customers

WHERE email NOT LIKE '%@example.invalid';

Expected output

User altered.

User altered.

842117 rows updated.

Commit complete.

UNMASKED_EMAILS
---------------
              0

What to expect: New passwords that are different from production's, and no customer email left that could receive a real message. Run the masking before the test service is opened to testers, and keep the masking script under version control so every monthly refresh repeats it exactly.



Step 9: Open It to the Test Team and Clean Up

Re-enable the job queue for the jobs that should run in test, register a service for the testers, and remove the static listener entry if you no longer need it for the next refresh. Then take a first backup of the copy, so the test team can restore it if a test destroys data.


Shell

sqlplus -s / as sysdba <<'EOF'

ALTER SYSTEM SET job_queue_processes = 20 SCOPE = BOTH;

EXEC DBMS_SERVICE.CREATE_SERVICE('salestst_app', 'salestst_app.example.internal');

EXEC DBMS_SERVICE.START_SERVICE('salestst_app');

EOF

rman target / <<'EOF'

BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG TAG 'SALESTST_BASELINE';

EOF

Expected output

System altered.

PL/SQL procedure successfully completed.

PL/SQL procedure successfully completed.

Starting backup at 01-NOV-26
...
Finished backup at 01-NOV-26

What this does: The job queue runs again, now that the dangerous jobs are disabled, testers connect through their own service, and a baseline backup protects the copy itself. Because the copy has its own DBID, this backup can safely go to the same backup storage or catalogue as production without any risk of confusion.



Summary

RMAN active duplicate builds a full, independent copy of a running database in another cloud without staging backups. Check that the source is in ARCHIVELOG mode, copy its password file to the target, start a minimal auxiliary instance in NOMOUNT with a static listener entry, and prove both Oracle Net connections. Run DUPLICATE FROM ACTIVE DATABASE with compressed backup sets, a section size and parallel channels, and override the name, storage, memory, jobs and redo destinations. Then confirm the new DBID, neutralise links and jobs, change passwords and mask personal data, and take a baseline backup before handing the copy over.

Recent Posts

See All

Comments


bottom of page