Oracle Database 12.1 introduced cross platform data transport using backup-sets. We could perform database/tablespace backups using FOR TRANSPORT/TO PLATFORM clause and restore the same to a different OS Platform. This typically involved 3 steps: create backup on source, copy backup-piece to destination and perform restoration on destination.
Starting from 12.2, we can perform cross platform transport of datafiles directly over the network using the FROM SERVICE clause along with the RESTORE FOREIGN DATAFILE command. This command internally performs a cross platform backup of the requested datafiles on the source, the backup-piece chunks are transferred to the destination over network and restoration is performed on destination.
Below steps demonstrate a cross platform transport of tablespace EXAMPLE from source platform AIX (Big Endian) to destination Linux (Little Endian):
1. On source, check the datafiles which belong to tablespace EXAMPLE:
SQL> select FILE_ID from DBA_DATA_FILES where TABLESPACE_NAME='EXAMPLE'; FILE_ID ---------- 2
2. On destination, perform a cross platform restore of datafiles belonging to source tablespace EXAMPLE using FROM SERVICE clause:
$ rman target sys/oracle@DEST122 RMAN> restore foreign datafile 2 2> format '/u01/app/oracle/oradata/DEST122/example01.dbf' 3> from service SRC122;
We can perform the migration using consistent or inconsistent backups. If using consistent backup, put the tablespace EXAMPLE in READ ONLY mode before running above restore command. If using inconsistent backups, the tablespace can remain in READ WRITE mode while performing an initial restore.
3. If above restoration was done with tablespace in READ ONLY mode, then recovery is not required. You can skip to the next step i.e. step# 4. However, if restoration was done with tablespace in READ WRITE mode, then we need to perform recovery. This can also be done directly over the network. Multiple recovery attempts can be performed while the source tablespace is in READ WRITE mode to sync it with the latest changes being done on source.
$ rman target sys/oracle@DEST122 RMAN> recover foreign datafilecopy '/u01/app/oracle/oradata/DEST122/example01.dbf' 2> from service SRC122;
Before, performing final recovery, put source tablepace in READ ONLY mode
SQL> alter tablespace EXAMPLE read only;
And, perform a final recovery on destination
$ rman target sys/oracle@DEST122 RMAN> recover foreign datafilecopy '/u01/app/oracle/oradata/DEST122/example01.dbf' 2> from service SRC122;
4. We now have a consistent datafile on the destination but it’s not yet plugged into the destination database. For this, we need to perform metadata export on the source and metadata import in the destination. We can also combine these 2 steps using the network_link option of impdp. For this, create a database link in the destination database pointing to the source database:
SQL> create public database link SRC122 connect to system identified by oracle using 'SRC122';
And then, perform the metadata import:
$ impdp system/password network_link=SRC122 transport_tablespaces=EXAMPLE transport_datafiles='/u01/app/oracle/oradata/DEST122/example01.dbf'