ORA-65118 during RESTORE FOREIGN DATAFILE/TABLESPACE

Starting with 12c Transportable Tablespaces can be combined with incremental backups to reduce the amount of time required to copy the Datafiles from the source to the target location. To do this RESTORE FOREIGN DATAFILE resp. TABLESPACE commands were introduced for RMAN.

In this blog post, I will show an issue when a backup of an 11.2.0.4 database is used as a source and a 19c PDB is used as target.

Preparation

To test this issue a level 0 backup of the USERS Tablespaces was created in the source database (11.2.0.4.200114), using the following RMAN command.

RMAN> BACKUP INCREMENTAL LEVEL 0 TABLESPACE "USERS" FORMAT '/u01/backup/users_inc0_11.2.0.4.bak';

Issue

Despite the fact that with Oracle 20c, the old architecture will be desupported, new databases should already use the container database (CDB) architecture.

In my lab environment, I want to transport the source Tablespaces to my PDB called TVDPDB1. To do this, I connect to this PDB – I use a special common user C##RMAN, which has the SYSBACKUP privilege.

RMAN> CONNECT TARGET 'c##rman/rman@localhost:1521/TVDPDB1.trivadistraining.com AS SYSBACKUP'

connected to target database: TVDCDB1:TVDPDB1 (DBID=1625907810)

Now I am able to restore the foreign Datafiles resp. Tablespaces – I use Oracle Managed FIles (OMF) by adding the TO NEW clause.

RMAN> RUN {
   RESTORE FROM PLATFORM 'Linux x86 64-bit' FOREIGN TABLESPACE "USERS"
   TO NEW
   FROM BACKUPSET '/u01/backup/users_inc0_11.2.0.4.bak';
}

Starting restore at 20.04.20
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring all foreign files in backup piece
channel ORA_DISK_1: reading from backup piece /u01/app/stage/users_inc0_11.2.0.4.bak
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 04/20/2020 09:50:30
ORA-19870: error while restoring backup piece /u01/backup/users_inc0_11.2.0.4.bak
ORA-65118: operation affecting a pluggable database cannot be performed from another pluggable database

CAUTION: If the source backup is taken from an 11g database, the FROM PLATFORM clause is mandatory, even if the source and target platform are the same. Otherwise, ORA-19988 is raised.

ORA-19988: must specify FROM PLATFORM for cross-platform restore of backup sets with pre-12.1 compatibility

Analyze

When the error occurs, the following message is written to the alert log.

2020-04-20T09:50:29.493504+02:00
TVDPDB1(3):ORA-65118: backup piece belonging to PDB 1 is attempted an access from PDB 3

It looks like that RMAN thinks, that the backup belongs to the CDB$ROOT container (ID: 1). But in 11g the was no CDB architecture. Let’s do the same restore in a 19c non-CDB.

RMAN> CONNECT TARGET /

connected to target database: TVDDB1 (DBID=2538770445)

RMAN> RUN {
   RESTORE FROM PLATFORM 'Linux x86 64-bit' FOREIGN TABLESPACE "USERS"
   TO NEW
   FROM BACKUPSET '/u01/backup/users_inc0_11.2.0.4.bak';
}

Starting restore at 20.04.20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=32 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring all files in foreign tablespace USERS
channel ORA_DISK_1: reading from backup piece /u01/backup/users_inc0_11.2.0.4.bak
channel ORA_DISK_1: restoring foreign file 5 to /u01/oradata/TVDDB1_SITE1/datafile/o1_mf__h9toqhs0_.dbf
channel ORA_DISK_1: foreign piece handle=/u01/backup/users_inc0_11.2.0.4.bak
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 20.04.20

The restore succeeded. Now I try to restore a backup of a 12.1.0.2 Tablespaces to my 19c PDB.

RMAN> CONNECT TARGET 'c##rman/rman@localhost:1521/TVDPDB1.trivadistraining.com AS SYSBACKUP'

connected to target database: TVDCDB1:TVDPDB1 (DBID=1625907810)

RMAN> RUN {
   RESTORE FROM PLATFORM 'Linux x86 64-bit' FOREIGN TABLESPACE "USERS"
   TO NEW
   FROM BACKUPSET '/u01/backup/users_inc0_12.1.0.2.bak';
}

Starting restore at 20.04.20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=37 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring all files in foreign tablespace USERS
channel ORA_DISK_1: reading from backup piece /u01/backup/users_inc0_12.1.0.2.bak
channel ORA_DISK_1: restoring foreign file 6 to /u01/oradata/TVDCDB1_SITE1/9211F09534461015E0536619A8C0D99B/datafile/o1_mf_users_h9tp7s26_.dbf
channel ORA_DISK_1: foreign piece handle=/u01/backup/users_inc0_12.1.0.2.bak
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
Finished restore at 20.04.20

This was also possible. So the error only occurs when a 11g backup is used.

Solution

Currently, I am not aware of a solution for this issue. A service request is still pending.

Update 04.05.2020
In the meantime, unpublished Bug 31272525 – ORA-65118 – RESTORE FOREIGN TABLESPACE DATAFILES OF A 11.2.0.4 TO A 19C PDB was created for this issue.

I also checked if 18c is affected by this issue and I was able to restore the foreign Tablespaces/Datafiles without any errors.

Workaround

At least a workaround is available. Instead of connecting to the PDB, you can connect to the CDB to restore and recover the foreign Datafiles.

RMAN> CONNECT TARGET /

connected to target database: TVDCDB1 (DBID=36586750)

RUN {
   RESTORE FROM PLATFORM 'Linux x86 64-bit' FOREIGN TABLESPACE "USERS"
   TO NEW
   FROM BACKUPSET '/u01/backup/users_inc0_11.2.0.4.bak';
}

Starting restore at 20.04.20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=37 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring all files in foreign tablespace USERS
channel ORA_DISK_1: reading from backup piece /u01/backup/users_inc0_11.2.0.4.bak
channel ORA_DISK_1: restoring foreign file 5 to /u01/oradata/TVDCDB1_SITE1/datafile/o1_mf__h9tpmbvv_.dbf
channel ORA_DISK_1: foreign piece handle=/u01/backup/users_inc0_11.2.0.4.bak
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 20.04.20

CAUTION: When Oracle Managed Files (OMF) are used, the Datafiles are restored to the wrong location. An (online) Datafile move is required, after the metadata export of the Transportable Tablespaces is executed.

References