RMAN Convert between different platforms (Solaris -> Linux)

https://docs.oracle.com/cd/E11882_01/backup.112/e10642/rcmxplat.htm#BRADV89983
For this, I created a tablespace in a SUN Solaris 12c environment and did an export tts.

Tablespace name: TS_TEST
Schema Objects : HR
Objects : T1, T2, T3 tables, to checked inside of PDBPROD3 after the import
TARGET : CDBPROD:PDBPROD3 
All tables have 39 rows

Export:

BANNER CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production 0
PL/SQL Release 12.1.0.2.0 - Production 0
CORE 12.1.0.2.0 Production 0
TNS for Solaris: Version 12.1.0.2.0 - Production 0
NLSRTL Version 12.1.0.2.0 - Production 0

SQL> SELECT PLATFORM_NAME
FROM V$TRANSPORTABLE_PLATFORM
WHERE PLATFORM_ID =
 ( SELECT PLATFORM_ID
 FROM V$DATABASE ); 2 3 4 5

PLATFORM_NAME
-----------------------------------------------------------------------------------------------------
Solaris Operating System (x86-64)

SQL> alter tablespace ts_test read only;
Tablespace altered.

PDB: PDDPOC01
oracle@vdds-racdb-01:~$ expdp hr/hr@PDDPOC01 directory=dir_tmp transport_tablespaces=ts_test

Export: Release 12.1.0.2.0 - Production on Thu Nov 30 16:09:10 2017
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
Starting "HR"."SYS_EXPORT_TRANSPORTABLE_01": hr/********@PDDPOC01 directory=dir_tmp transport_tablespaces=ts_test
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/STATISTICS/MARKER
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Master table "HR"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for HR.SYS_EXPORT_TRANSPORTABLE_01 is:

/tmp/expdat.dmp

******************************************************************************

Datafiles required for transportable tablespace TS_TEST:
 +DATA/DDDSRACDB0/5926684743AC6B8BE054020820FA629A/DATAFILE/ts_test.dbf

Job "HR"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at Thu Nov 30 16:10:03 2017 elapsed 0 00:00:42

ORACLE_SID = [DDDSRACD1] ? +ASM1
The Oracle base remains unchanged with value /u01/oracle
oracle@vdds-racdb-01:~$ asmcmd cp +DATA/DDDSRACDB0/5926684743AC6B8BE054020820FA629A/DATAFILE/ts_test.dbf /tmp

copying +DATA/DDDSRACDB0/5926684743AC6B8BE054020820FA629A/DATAFILE/ts_test.dbf -> /tmp/ts_test.dbf




racle@racdb01:/tmp$ ls -ltr
total 20968
drwxr----- 2 oracle oinstall 178 Nov 30 10:53 hsperfdata_oracle
drwxrwxrwx 2 root root 117 Nov 30 16:30 oracle
-rw-r----- 1 oracle oinstall 229376 Nov 30 16:36 test.dmp
-rw-r----- 1 oracle oinstall 10493952 Nov 30 16:37 ts_test.dbf
drwxr-xr-x 2 root root 302 Nov 30 16:37 hsperfdata_root

ON VM1:

-rwxr-x---. 1 oracle oinstall 229376 Nov 30 16:39 test.dmp
-rwxr-x---. 1 oracle oinstall 10493952 Nov 30 16:39 ts_test.dbf

[oracle@vm1 dba]$ pwd

/home/oracle/dba

Copy the files to an existent directory into the server or create a new directory to be used during the import:

SQL> !ls -ltr /home/oracle/dba
total 10476
-rw-r--r--. 1 oracle oinstall 137 Nov 27 16:53 afiedt.buf
drwxrwxrwx. 2 oracle oinstall 64 Nov 30 10:56 scripts
-rwxr-x---. 1 oracle oinstall 229376 Nov 30 16:39 test.dmp
-rwxr-x---. 1 oracle oinstall 10493952 Nov 30 16:39 ts_test.dbf

SQL> create or replace directory dir_dba as '/home/oracle/dba';

Directory created.

SQL> grant read,write on directory dir_dba to public;

Grant succeeded.

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
 5 PDBPROD3 READ WRITE NO

Convert the datafile:

SELECT PLATFORM_NAME, ENDIAN_FORMAT
FROM V$TRANSPORTABLE_PLATFORM;

Convert to the same directory where the datafiles are placed.

rman target /

RMAN> CONVERT DATAFILE '/home/oracle/dba/ts_test.dbf'
DB_FILE_NAME_CONVERT '/home/oracle/dba', '/u02/oradata/cdbprod/pdbprod3'
FROM PLATFORM 'Solaris Operating System (x86-64)';
2> 3>

Starting conversion at target at 30-NOV-17
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
channel ORA_DISK_1: starting datafile conversion
input file name=/home/oracle/dba/ts_test.dbf
converted datafile=/u02/oradata/cdbprod/pdbprod3/ts_test.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
Finished conversion at target at 30-NOV-17

Starting Control File and SPFILE Autobackup at 30-NOV-17
piece handle=/u03/fra/CDBPROD/autobackup/2017_11_30/o1_mf_s_961435712_f20dfjv3_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 30-NOV-17

[oracle@vm1 datafile]$ ls -ltr /u02/oradata/cdbprod/pdbprod3/ts_test.dbf
-rw-r-----. 1 oracle oinstall 10493952 Nov 30 17:28 /u02/oradata/cdbprod/pdbprod3/ts_test.dbf

Check the TNS entry for PDBPROD3

PDBPROD3 =
 (DESCRIPTION =
 (ADDRESS_LIST =
 (ADDRESS = (PROTOCOL = TCP)(HOST = vm1)(PORT = 1521))
 )
 (CONNECT_DATA =
 (SERVER = DEDICATED)
 (SERVICE_NAME = pdbprod3)
 )
 )

--> Import the datafile

impdp system/oracle@pdbprod3 dumpfile=test.dmp directory=dir_dba transport_datafiles=/u02/oradata/cdbprod/pdbprod3/ts_test.dbf

Import: Release 12.1.0.2.0 - Production on Thu Nov 30 17:34:50 2017
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded
Source time zone is +02:00 and target time zone is +00:00.

Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01": system/********@pdbprod3 dumpfile=test.dmp directory=dir_dba transport_datafiles=/u02/oradata/cdbprod/pdbprod3/ts_test.dbf
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/STATISTICS/MARKER
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at Thu Nov 30 17:35:34 2017 elapsed 0 00:00:41

--> Check the information

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
 2 PDB$SEED READ ONLY NO
 3 PDBPROD1 READ WRITE NO
 4 PDBPROD2 READ WRITE NO
 5 PDBPROD3 READ WRITE NO
 6 PDBPROD4 READ WRITE NO

SQL> alter session set container=PDBPROD3;

Session altered.

SQL> SELECT COUNT(*) FROM HR.T1;
 COUNT(*)
----------
 39

SQL> SELECT COUNT(*) FROM HR.t2;
 COUNT(*)
----------
 39

SQL> SELECT COUNT(*) FROM HR.t3;
 COUNT(*)
----------
 39
Advertisements

RMAN Restore Database

-- Before start
get the info on the ALERT.LOG regarding last TIMESTAMP valid, 
the last time before the crash;

Example:

Wed Jan 04 15:28:43 2017
Thread 1 advanced to log sequence 8725 (LGWR switch)
  Current log# 3 seq# 8725 mem# 0: /u01/oradata/dbtst/redo03.log
Wed Jan 04 15:28:43 2017 <------------------------------------------------------------ * THIS ON THIS CASE
Archived Log entry 13322 added for thread 1 sequence 8724 ID 0xee867f48 dest 1:
Wed Jan 04 15:43:40 2017
Errors in file /u01/oracle/diag/rdbms/dbtst/dbtst/trace/dbtst_m002_10209.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/u01/oradata/dbtst/redo01.log'
ORA-27037: unable to obtain file status
/15:43:40 2017 


1.)
rman target /

list backup of controlfile:

(take the last one)

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
8421    Full    14.92M     DISK        00:00:01     04-JAN-17
        BP Key: 8421   Status: AVAILABLE  Compressed: NO  Tag: TAG20170104T051133
        Piece Name: /oracle_backups/ITT/dbtst_ctl_s_DBTST932361094u5rp5cs6_1_1
  Standby Control File Included: Ckp SCN: 60656341385   Ckp time: 04-JAN-17


2.)
Controlfile Location:

sqlplus / as sysdba

show parameter control;

/u01/oradata/dbtst/control01.ctl, /u01/oradata/dbtst/control02.ctl

3.) Check if still have the controlfiles:

[oracle@lnx01/ SID : dbtst]$ ls -ltr
total 45744
-rw-r----- 1 oracle oinstall 15613952 Jan  4 13:48 snapcf_dbtst.ctl
-rw-r----- 1 oracle oinstall 15613952 Jan  4 16:26 control02.ctl
-rw-r----- 1 oracle oinstall 15613952 Jan  4 16:26 control01.ctl

4.) Try first do the restore using the existent controlfile, 
if doesn't have anymore the files you need use the backup on the STEP 1, 
to restore the latest controlfile before start
the restore database operation;

JUST in case of you don't have any more the CONTROLFILES execute the step below:

rman target /

startup nomount;

RESTORE CONTROLFILE FROM "/oracle_backups/ITT/dbtst_ctl_s_DBTST932361094u5rp5cs6_1_1"; 

If the CONTROLFILES are in place, proceed like below:

rman target /
startup mount;

run
{
set until time "to_date('04-JAN-2017:15:28:43', 'DD-MON-YYYY:HH24:MI:SS')" ; 
restore database;
recover database;
}

RMAN> alter database open resetlogs;

Statement processed

Flashback Database – Enable/Disable

Hi, this is the quick one, sometimes we forget the basic stuffs, so …
https://docs.oracle.com/cd/E11882_01/backup.112/e10642/flashdb.htm#BRADV582

--- Enable Flashback Database:

select FLASHBACK_ON from v$database;

1.) Choose the DIRECTORY:
/u01/oradata/KDBPP/FRA

2.) SHUT Immediate;

3.) Startup mount;

4.) Enable Archivelog Mode, if needed

alter database archivelog;

5.) Define the FRA - Size:
alter system set db_recovery_file_dest_size=50g scope=both;

6.) Define the FRA - Directory:
alter system set db_recovery_file_dest='/u01/oradata/KDBPP/FRA' scope=both;

7.) Enable FLASHBACK on DATABASE:
alter database flashback on;

8.) Open database:
alter database open;

-- Disable:
1.) Shutdown Database;
shut immediate;

2.) Startup mount;

3.) alter database flashback off;

4.) If needed, disable the Archivelog
alter database noarchivelog;

5.) alter database open;

select FLASHBACK_ON from v$database;

--------------------------------------------------------------------
Note:

If you face this issue (ORA-38781: cannot disable media recovery - 
have guaranteed restore points) trying put back in NOARCHIVELOG mode.

You need drop the active restore point before, so :

a.) SELECT NAME, SCN, TIME, DATABASE_INCARNATION#,
        GUARANTEE_FLASHBACK_DATABASE,STORAGE_SIZE
        FROM V$RESTORE_POINT; 

b.) drop restore point <RESTORE POINT NAME>;

c.) if you are in MOUNT state you can execute:
alter database noarchivelog;


Recover Pluggable Database

http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/12c/r1/pdb/pdb_pitr/pdb_pitr.html
https://oracle-base.com/articles/12c/multitenant-rman-backup-recovery-cdb-and-pdb-12cr1#pdb-recovery

Tested on:

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options


1.) Simulating some erros on PDB1:

 select name, open_mode from v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PDB1                           MOUNTED
PDB3                           MOUNTED

alter pluggable database all open;

Pluggable database altered.

select name, open_mode from v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PDB1                           READ WRITE
PDB3                           READ WRITE

alter session set container=pdb1;

 select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
TEMP


create tablespace ts_pdb1 datafile '/oracle/oradata/CDB/pdb1/ts_pdb1.dbf' size 10m;

Tablespace created.

alter user test default tablespace ts_pdb1;

User altered.

alter user test quota unlimited on ts_pdb1;

User altered.

--> To connect directly on PDB:

alter system set local_listener='lnx01:1521' scope=both;

select con_id, name, open_mode from v$pdbs;

              CON_ID NAME                           OPEN_MODE
-------------------- ------------------------------ ----------
                   2 PDB$SEED                       READ ONLY
                   3 PDB1                           READ WRITE <===
                   5 PDB3                           READ WRITE

 conn test/test@pdb1
Connected.

show con_id

CON_ID
------------------------------
3

insert into t1 values (1,to_char(sysdate,'ddmmyyyy-hh24miss'));
insert into t1 values (2,to_char(sysdate,'ddmmyyyy-hh24miss'));
insert into t1 values (3,to_char(sysdate,'ddmmyyyy-hh24miss'));

commit;
        
select scn from v$database;

 select CURRENT_SCN from v$database;

         CURRENT_SCN
--------------------
             2058379
             
insert into TEST.t1 values (4,'AFTER SCN 2058379');

commit;

 SELECT * FROM TEST.T1;

                 NUM TEXT
-------------------- ---------------------
                   1 06032016-141735
                   2 06032016-141735
                   3 06032016-141735
                   4 AFTER SCN 2058379


2.) Listing backups:

RMAN> LIST BACKUP OF PLUGGABLE DATABASE PDB1;

using target database control file instead of recovery catalog

List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
22      Full    603.45M    DISK        00:00:04     06-MAR-16
        BP Key: 22   Status: AVAILABLE  Compressed: NO  Tag: TAG20160306T132621
        Piece Name: /data02/backup/CDB/CDB_0mqvq6cc_1_1
  List of Datafiles in backup set 22
  Container ID: 3, PDB Name: PDB1
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  16      Full 2053591    06-MAR-16 /oracle/oradata/CDB/pdb1/system01.dbf
  17      Full 2053591    06-MAR-16 /oracle/oradata/CDB/pdb1/sysaux01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
27      Full    603.45M    DISK        00:00:04     06-MAR-16
        BP Key: 27   Status: AVAILABLE  Compressed: NO  Tag: TAG20160306T133029
        Piece Name: /data02/backup/CDB/CDB_0rqvq6jl_1_1
  List of Datafiles in backup set 27
  Container ID: 3, PDB Name: PDB1
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  16      Full 2053591    06-MAR-16 /oracle/oradata/CDB/pdb1/system01.dbf
  17      Full 2053591    06-MAR-16 /oracle/oradata/CDB/pdb1/sysaux01.dbf

  
--> Please note that SCN from Backup is lower than desired SCN:

3.) Recover PDB1 until  scn: 2058379

 show con_id

CON_ID
------------------------------
3


shut immediate;

Pluggable Database closed.

 show con_id
 
CON_ID
------------------------------
1

select name, con_id, open_mode from v$pdbs;

NAME                                         CON_ID OPEN_MODE
------------------------------ -------------------- ----------
PDB$SEED                                          2 READ ONLY
PDB1                                              3 MOUNTED
PDB3                                              5 READ WRITE

rman target /

RUN {
  SET UNTIL scn 2058379;
  RESTORE PLUGGABLE DATABASE pdb1;
  RECOVER PLUGGABLE DATABASE pdb1;
  ALTER PLUGGABLE DATABASE pdb1 OPEN RESETLOGS;
}

                2> 3> 4> 5> 6>
executing command: SET until clause

Starting restore at 06-MAR-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=27 device type=DISK

creating datafile file number=20 name=/oracle/oradata/CDB/pdb1/ts_pdb1.dbf
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 datafile 00016 to /oracle/oradata/CDB/pdb1/system01.dbf
channel ORA_DISK_1: restoring datafile 00017 to /oracle/oradata/CDB/pdb1/sysaux01.dbf
channel ORA_DISK_1: reading from backup piece /data02/backup/CDB/CDB_0rqvq6jl_1_1
channel ORA_DISK_1: piece handle=/data02/backup/CDB/CDB_0rqvq6jl_1_1 tag=TAG20160306T133029
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 06-MAR-16

Starting recover at 06-MAR-16
current log archived
using channel ORA_DISK_1
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified Point-in-Time

List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS1

Creating automatic instance, with SID='ecby'

initialization parameters used for automatic instance:
db_name=CDB
db_unique_name=ecby_pitr_pdb1_CDB
compatible=12.1.0.2.0
db_block_size=8192
db_files=200
diagnostic_dest=/oracle
_system_trig_enabled=FALSE
sga_target=800M
processes=200
#No auxiliary destination in use
enable_pluggable_database=true
_clone_one_pdb_recovery=true
control_files=/oracle/fast_recovery_area/CDB/controlfile/o1_mf_cfs13q8s_.ctl
#No auxiliary parameter file used


starting up automatic instance CDB

Oracle instance started

Total System Global Area     838860800 bytes

Fixed Size                     2929936 bytes
Variable Size                230689520 bytes
Database Buffers             599785472 bytes
Redo Buffers                   5455872 bytes
Automatic instance created

contents of Memory Script:
{
# set requested point in time
set until  scn 2058379;
# restore the controlfile
restore clone controlfile;

# mount the controlfile
sql clone 'alter database mount clone database';
}
executing Memory Script

executing command: SET until clause

Starting restore at 06-MAR-16
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=12 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /oracle/fast_recovery_area/CDB/autobackup/2016_03_06/o1_mf_s_905781318_cfrz8pqp_.bkp
channel ORA_AUX_DISK_1: piece handle=/oracle/fast_recovery_area/CDB/autobackup/2016_03_06/o1_mf_s_905781318_cfrz8pqp_.bkp tag=TAG20160306T135518
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/oracle/fast_recovery_area/CDB/controlfile/o1_mf_cfs13q8s_.ctl
Finished restore at 06-MAR-16

sql statement: alter database mount clone database

contents of Memory Script:
{
# set requested point in time
set until  scn 2058379;
# switch to valid datafilecopies
switch clone datafile  16 to datafilecopy
 "/oracle/oradata/CDB/pdb1/system01.dbf";
switch clone datafile  17 to datafilecopy
 "/oracle/oradata/CDB/pdb1/sysaux01.dbf";
switch clone datafile  20 to datafilecopy
 "/oracle/oradata/CDB/pdb1/ts_pdb1.dbf";
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile  1 to
 "/oracle/fast_recovery_area/CDB/datafile/o1_mf_system_cfs140md_.dbf";
set newname for datafile  4 to
 "/oracle/fast_recovery_area/CDB/datafile/o1_mf_undotbs1_cfs140n4_.dbf";
set newname for datafile  3 to
 "/oracle/fast_recovery_area/CDB/datafile/o1_mf_sysaux_cfs140n9_.dbf";
set newname for datafile  6 to
 "/oracle/fast_recovery_area/CDB/datafile/o1_mf_users_cfs149f8_.dbf";
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile  1, 4, 3, 6;

switch clone datafile all;
}
executing Memory Script

executing command: SET until clause

datafile 16 switched to datafile copy
input datafile copy RECID=4 STAMP=905783225 file name=/oracle/oradata/CDB/pdb1/system01.dbf

datafile 17 switched to datafile copy
input datafile copy RECID=5 STAMP=905783225 file name=/oracle/oradata/CDB/pdb1/sysaux01.dbf

datafile 20 switched to datafile copy
input datafile copy RECID=6 STAMP=905783225 file name=/oracle/oradata/CDB/pdb1/ts_pdb1.dbf

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 06-MAR-16
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /oracle/fast_recovery_area/CDB/datafile/o1_mf_system_cfs140md_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /oracle/fast_recovery_area/CDB/datafile/o1_mf_undotbs1_cfs140n4_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /oracle/fast_recovery_area/CDB/datafile/o1_mf_sysaux_cfs140n9_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00006 to /oracle/fast_recovery_area/CDB/datafile/o1_mf_users_cfs149f8_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /data02/backup/CDB/CDB_0lqvq6bt_1_1
channel ORA_AUX_DISK_1: piece handle=/data02/backup/CDB/CDB_0lqvq6bt_1_1 tag=TAG20160306T132621
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 06-MAR-16

datafile 1 switched to datafile copy
input datafile copy RECID=11 STAMP=905783240 file name=/oracle/fast_recovery_area/CDB/datafile/o1_mf_system_cfs140md_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=12 STAMP=905783240 file name=/oracle/fast_recovery_area/CDB/datafile/o1_mf_undotbs1_cfs140n4_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=13 STAMP=905783240 file name=/oracle/fast_recovery_area/CDB/datafile/o1_mf_sysaux_cfs140n9_.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=14 STAMP=905783241 file name=/oracle/fast_recovery_area/CDB/datafile/o1_mf_users_cfs149f8_.dbf

contents of Memory Script:
{
# set requested point in time
set until  scn 2058379;
# online the datafiles restored or switched
sql clone "alter database datafile  1 online";
sql clone "alter database datafile  4 online";
sql clone "alter database datafile  3 online";
sql clone 'PDB1' "alter database datafile
 16 online";
sql clone 'PDB1' "alter database datafile
 17 online";
sql clone 'PDB1' "alter database datafile
 20 online";
sql clone "alter database datafile  6 online";
# recover pdb
recover clone database tablespace  "SYSTEM", "UNDOTBS1", "SYSAUX", "USERS" pluggable database
 'PDB1'   delete archivelog;
sql clone 'alter database open read only';
plsql <<<begin
   add_dropped_ts;
end; >>>;
plsql <<<begin
   save_pdb_clean_scn;
end; >>>;
# shutdown clone before import
shutdown clone abort
plsql <<<begin
   pdbpitr_inspect(pdbname =>  'PDB1');
end; >>>;
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile  1 online

sql statement: alter database datafile  4 online

sql statement: alter database datafile  3 online

sql statement: alter database datafile  16 online

sql statement: alter database datafile  17 online

sql statement: alter database datafile  20 online

sql statement: alter database datafile  6 online

Starting recover at 06-MAR-16
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 90 is already on disk as file /data01/CDB/archives/1_90_900491294.dbf
archived log for thread 1 with sequence 91 is already on disk as file /data01/CDB/archives/1_91_900491294.dbf
archived log file name=/data01/CDB/archives/1_90_900491294.dbf thread=1 sequence=90
archived log file name=/data01/CDB/archives/1_91_900491294.dbf thread=1 sequence=91
media recovery complete, elapsed time: 00:00:01
Finished recover at 06-MAR-16

sql statement: alter database open read only



Oracle instance shut down


Removing automatic instance
Automatic instance removed
auxiliary instance file /oracle/fast_recovery_area/CDB/datafile/o1_mf_sysaux_cfs140n9_.dbf deleted
auxiliary instance file /oracle/fast_recovery_area/CDB/controlfile/o1_mf_cfs13q8s_.ctl deleted
Finished recover at 06-MAR-16

Statement processed

4.) Checking after recovery

 show con_id

CON_ID
------------------------------
1
14:28:19 SQL> select name, con_id, open_mode from v$pdbs;

NAME                                         CON_ID OPEN_MODE
------------------------------ -------------------- ----------
PDB$SEED                                          2 READ ONLY
PDB1                                              3 READ WRITE
PDB3                                              5 READ WRITE

3 rows selected.

 conn test/test@pdb1;
Connected.

 SELECT * FROM TEST.T1;

                 NUM TEXT
-------------------- --------------------
                   1 06032016-141735
                   2 06032016-141735
                   3 06032016-141735

Backup Pluggable Database

http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/12c/r1/pdb/pdb_pitr/pdb_pitr.html

Tested on: 
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

1.) Listing PDBS:

13:05:01 SQL> select name, open_mode from v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PDB1                           MOUNTED
PDB3                           MOUNTED


2.) Opening PDBs:

alter pluggable database all open;

Pluggable database altered.

select name, open_mode from v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PDB1                           READ WRITE
PDB3                           READ WRITE

3.) Backup directory:

/data02/backup/CDB

4.) Database in archive MODE:

archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /data01/CDB/archives
Oldest online log sequence     87
Next log sequence to archive   89
Current log sequence           89

5.) Flashback database enabled:

db_recovery_file_dest                string      /oracle/fast_recovery_area
db_recovery_file_dest_size           big integer 4560M

db_flashback_retention_target        integer     1440

select FLASHBACK_ON from v$database;

FLASHBACK_ON
------------------
NO

shut immediate;
startup mount;
alter database flashback on;
alter database open;

 select FLASHBACK_ON from v$database;

FLASHBACK_ON
------------------
YES


5.) Backup CDB:

rman target /

configure controlfile autobackup on;

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

 configure channel device type disk format '/data02/backup/CDB/CDB_%U';

new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/data02/backup/CDB/CDB_%U';
new RMAN configuration parameters are successfully stored

 backup database plus archivelog;


Starting backup at 06-MAR-16
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=28 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=77 RECID=1 STAMP=901791271
input archived log thread=1 sequence=78 RECID=2 STAMP=901791829
input archived log thread=1 sequence=79 RECID=3 STAMP=901791879
input archived log thread=1 sequence=80 RECID=4 STAMP=901794646
input archived log thread=1 sequence=81 RECID=5 STAMP=905701139
input archived log thread=1 sequence=82 RECID=6 STAMP=905701398
input archived log thread=1 sequence=83 RECID=7 STAMP=905701551
input archived log thread=1 sequence=84 RECID=8 STAMP=905778404
input archived log thread=1 sequence=85 RECID=9 STAMP=905778523
input archived log thread=1 sequence=86 RECID=10 STAMP=905778549
input archived log thread=1 sequence=87 RECID=11 STAMP=905778576
input archived log thread=1 sequence=88 RECID=12 STAMP=905778589
input archived log thread=1 sequence=89 RECID=13 STAMP=905779578
channel ORA_DISK_1: starting piece 1 at 06-MAR-16
channel ORA_DISK_1: finished piece 1 at 06-MAR-16
piece handle=/data02/backup/CDB/CDB_0kqvq6bq_1_1 tag=TAG20160306T132618 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 06-MAR-16

Starting backup at 06-MAR-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/oracle/oradata/CDB/undotbs01.dbf
input datafile file number=00001 name=/oracle/oradata/CDB/system01.dbf
input datafile file number=00003 name=/oracle/oradata/CDB/sysaux01.dbf
input datafile file number=00006 name=/oracle/oradata/CDB/users01.dbf
channel ORA_DISK_1: starting piece 1 at 06-MAR-16
channel ORA_DISK_1: finished piece 1 at 06-MAR-16
piece handle=/data02/backup/CDB/CDB_0lqvq6bt_1_1 tag=TAG20160306T132621 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00017 name=/oracle/oradata/CDB/pdb1/sysaux01.dbf
input datafile file number=00016 name=/oracle/oradata/CDB/pdb1/system01.dbf
channel ORA_DISK_1: starting piece 1 at 06-MAR-16
channel ORA_DISK_1: finished piece 1 at 06-MAR-16
piece handle=/data02/backup/CDB/CDB_0mqvq6cc_1_1 tag=TAG20160306T132621 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00019 name=+DATA/CDB/PDB3/sysaux01.dbf
input datafile file number=00018 name=+DATA/CDB/PDB3/system01.dbf
channel ORA_DISK_1: starting piece 1 at 06-MAR-16
channel ORA_DISK_1: finished piece 1 at 06-MAR-16
piece handle=/data02/backup/CDB/CDB_0nqvq6cj_1_1 tag=TAG20160306T132621 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/oracle/oradata/CDB/pdbseed/sysaux01.dbf
input datafile file number=00005 name=/oracle/oradata/CDB/pdbseed/system01.dbf
channel ORA_DISK_1: starting piece 1 at 06-MAR-16
channel ORA_DISK_1: finished piece 1 at 06-MAR-16
piece handle=/data02/backup/CDB/CDB_0oqvq6cr_1_1 tag=TAG20160306T132621 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 06-MAR-16

Starting backup at 06-MAR-16
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=90 RECID=14 STAMP=905779618
channel ORA_DISK_1: starting piece 1 at 06-MAR-16
channel ORA_DISK_1: finished piece 1 at 06-MAR-16
piece handle=/data02/backup/CDB/CDB_0pqvq6d2_1_1 tag=TAG20160306T132658 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 06-MAR-16

Starting Control File and SPFILE Autobackup at 06-MAR-16
piece handle=/oracle/fast_recovery_area/CDB/autobackup/2016_03_06/o1_mf_s_905779619_cfrxmmm0_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 06-MAR-16

6.) Backup PDB

BACKUP PLUGGABLE DATABASE pdb1;

Starting backup at 06-MAR-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00017 name=/oracle/oradata/CDB/pdb1/sysaux01.dbf
input datafile file number=00016 name=/oracle/oradata/CDB/pdb1/system01.dbf
channel ORA_DISK_1: starting piece 1 at 06-MAR-16
channel ORA_DISK_1: finished piece 1 at 06-MAR-16
piece handle=/data02/backup/CDB/CDB_0rqvq6jl_1_1 tag=TAG20160306T133029 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 06-MAR-16

Starting Control File and SPFILE Autobackup at 06-MAR-16
piece handle=/oracle/fast_recovery_area/CDB/autobackup/2016_03_06/o1_mf_s_905779836_cfrxtf16_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 06-MAR-16

7.) Listing Backups:

list backup of database summary;


List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
21      B  F  A DISK        06-MAR-16       1       1       NO         TAG20160306T132621
22      B  F  A DISK        06-MAR-16       1       1       NO         TAG20160306T132621
23      B  F  A DISK        06-MAR-16       1       1       NO         TAG20160306T132621
24      B  F  A DISK        06-MAR-16       1       1       NO         TAG20160306T132621
27      B  F  A DISK        06-MAR-16       1       1       NO         TAG20160306T133029


list backup  of pluggable database pdb1;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
22      Full    603.45M    DISK        00:00:04     06-MAR-16
        BP Key: 22   Status: AVAILABLE  Compressed: NO  Tag: TAG20160306T132621
        Piece Name: /data02/backup/CDB/CDB_0mqvq6cc_1_1
  List of Datafiles in backup set 22
  Container ID: 3, PDB Name: PDB1
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  16      Full 2053591    06-MAR-16 /oracle/oradata/CDB/pdb1/system01.dbf
  17      Full 2053591    06-MAR-16 /oracle/oradata/CDB/pdb1/sysaux01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
27      Full    603.45M    DISK        00:00:04     06-MAR-16
        BP Key: 27   Status: AVAILABLE  Compressed: NO  Tag: TAG20160306T133029
        Piece Name: /data02/backup/CDB/CDB_0rqvq6jl_1_1
  List of Datafiles in backup set 27
  Container ID: 3, PDB Name: PDB1
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  16      Full 2053591    06-MAR-16 /oracle/oradata/CDB/pdb1/system01.dbf
  17      Full 2053591    06-MAR-16 /oracle/oradata/CDB/pdb1/sysaux01.dbf

Flashback Data Archive

https://docs.oracle.com/cd/B28359_01/appdev.111/b28424/adfns_flashback.htm#BJFFDCEH
1.) Grant
SQL> conn / as sysdba
 Connected.
 SQL>
 SQL>
 SQL> grant flashback archive administer to cmagno;
Grant succeeded.
SQL>
2.) tablespaces:
SQL> select tablespace_name, contents, status from dba_tablespaces;
TABLESPACE_NAME                CONTENTS  STATUS
 ------------------------------ --------- ---------
 SYSTEM                         PERMANENT ONLINE
 SYSAUX                         PERMANENT ONLINE
 UNDOTBS1                       UNDO      ONLINE
 TEMP                           TEMPORARY ONLINE
 USERS                          PERMANENT ONLINE
 EXAMPLE                        PERMANENT ONLINE
create tablespace ts_fda datafile 'D:\APP\CANDRADE\ORADATA\DB01\TS_FDA_01.DBF' size 10m autoextend on next 10m maxsize 8g;
3.) Flashback Data Archive
create flashback archive FDA_01 tablespace ts_fda retention 1 month;
1* SELECT * FROM DBA_FLASHBACK_ARCHIVE
 SQL> /
OWNER_NAME      FLASHBACK_ARCHIVE_NAME         FLASHBACK_ARCHIVE# RETENTION_IN_DAYS CREATE_TIME                                                         LAST_PURGE_TIME                                                     STATUS
 --------------- ------------------------------ ------------------ ----------------- --------------------------------------------------------------------------- --------------------------------------------------------------------------- -------
 SYS             FDA_01                                          1                30 25-FEB-16 02.44.41.000000000 PM                                             25-FEB-16 02.44.41.000000000 PM
SQL> SELECT * FROM DBA_FLASHBACK_ARCHIVE_TS;
FLASHBACK_ARCHIVE_NAME         FLASHBACK_ARCHIVE# TABLESPACE_NAME                QUOTA_IN_MB
 ------------------------------ ------------------ ------------------------------ ------------------------
 FDA_01                                          1 TS_FDA
4.) Table
create table cmagno.FDA_TESTE
 (num number,
 text varchar2(1000))
 tablespace users;
insert into cmagno.FDA_TESTE values (1,'TEST FDA 1');
 insert into cmagno.FDA_TESTE values (2,'TEST FDA 2');
 insert into cmagno.FDA_TESTE values (3,'TEST FDA 3');
 COMMIT;
5.) FDA to the table:
alter table cmagno.FDA_TESTE flashback archive FDA_01;
SQL> select * from dba_FLASHBACK_ARCHIVE_TABLES;
TABLE_NAME                                                                                                               OWNER_NAME      FLASHBACK_ARCHIVE_NAME         ARCHIVE_TABLE_NAME                            STATUS
 -------------------------------------------------------------------------------------------------------------------------------- --------------- ------------------------------ ----------------------------------------------
 FDA_TESTE                                                                                                                CMAGNO          FDA_01                         SYS_FBA_HIST_93691                            ENABLED
1* select * from dba_FLASHBACK_ARCHIVE_TABLES
 SQL> /
TABLE_NAME           OWNER_NAME      FLASHBACK_ARCHIVE_NAME         ARCHIVE_TABLE_NAME                            STATUS
 -------------------- --------------- ------------------------------ -----------------------------------------------------
 FDA_TESTE            CMAGNO          FDA_01                         SYS_FBA_HIST_93691                            ENABLED
6.) Test
SQL> select to_char(sysdate,'dd-mon-rr hh24:mi:ss') from dual;
TO_CHAR(SYSDATE,'D
 ------------------
 25-feb-16 15:09:26
delete cmagno.FDA_TESTE;
 commit;
SQL> select count(*) from cmagno.FDA_TESTE;
COUNT(*)
 ----------
 0
SQL> select * from cmagno.FDA_TESTE as of timestamp to_timestamp('25-feb-16 15:09:26','dd-mon-rr hh24:mi:ss');
NUM TEXT
 ---------- --------------------------------------------------
 1 TEST FDA 1
 2 TEST FDA 2
 3 TEST FDA 3
SQL> show parameter undo
NAME                                 TYPE        VALUE
 ------------------------------------ ----------- -------------
 temp_undo_enabled                    boolean     FALSE
 undo_management                      string      AUTO
 undo_retention                       integer     900
 undo_tablespace                      string      UNDOTBS1
create undo tablespace undotbs2 datafile 'D:\APP\CANDRADE\ORADATA\DB01\UNDOTBS2_01.DBF' size 10m autoextend on next 10m maxsize 8g;
alter system set undo_tablespace=undotbs2 scope=both;
-- Just to show
SQL> shut immediate
 Database closed.
 Database dismounted.
 ORACLE instance shut down.
 SQL> startup
 ORACLE instance started.
Total System Global Area 5133828096 bytes
 Fixed Size                  3842712 bytes
 Variable Size            1107299688 bytes
 Database Buffers         4009754624 bytes
 Redo Buffers               12931072 bytes
 Database mounted.
 Database opened.
 SQL> show parameter undo
NAME                                 TYPE        VALUE
 ------------------------------------ ----------- --------------------
 temp_undo_enabled                    boolean     FALSE
 undo_management                      string      AUTO
 undo_retention                       integer     900
 undo_tablespace                      string      UNDOTBS2
 SQL>
SQL> select * from cmagno.FDA_TESTE as of timestamp to_timestamp('25-feb-16 15:09:26','dd-mon-rr hh24:mi:ss');
NUM TEXT
 ---------- --------------------------------------------------
 1 TEST FDA 1
 2 TEST FDA 2
 3 TEST FDA 3
SQL> truncate table cmagno.FDA_TESTE;
Table truncated.
SQL> select * from cmagno.FDA_TESTE as of timestamp to_timestamp('25-feb-16 15:09:26','dd-mon-rr hh24:mi:ss');
NUM TEXT
 ---------- --------------------------------------------------
 1 TEST FDA 1
 2 TEST FDA 2
 3 TEST FDA 3
SQL> create view cmagno.vw_fda as select * from cmagno.FDA_TESTE as of timestamp to_timestamp('25-feb-16 15:09:26','dd-mon-rr hh24:mi:ss');
View created.
SQL> select * from cmagno.vw_fda;
NUM TEXT
 ---------- --------------------------------------------------
 1 TEST FDA 1
 2 TEST FDA 2
 3 TEST FDA 3
SQL> select * from cmagno.FDA_TESTE;
no rows selected

FLASHBACK DATABASE – RESTORE POINT

FRA=> /u01/disk/clonetst/FRA
shut immediate;
 startup mount;
alter system set db_recovery_file_dest='/u01/disk/clonetst/FRA' SCOPE=both;
 alter system set db_recovery_file_dest_size=10G SCOPE=both;
 alter database archivelog; --- IF NOT IN ARCHIVE MODE
 alter database flashback on;
alter database open;
alter system set db_flashback_retention_target=2880; --- NEED CHOOSE THE BEST OPTION FOR YOUR ENVIRONMENT
clonetst > select flashback_on from v$database;
FLASHBACK_ON
 ------------------
 YES
clonetst > select * from v$restore_point;
no rows selected
-- Test Data
create table cmagno.teste_flashback
 (num number,
 sys_date date,
 info varchar2(1000));
clonetst > create restore point BEFORE_INSERT_DATA guarantee flashback database;
Restore point created.
1* select * from v$restore_point
 SYS @ clonetst > /
SCN DATABASE_INCARNATION# GUA         STORAGE_SIZE TIME                           RESTORE_POINT_TIME   PRE NAME
 -------------------- --------------------- --- -------------------- ------------------------------ -------------------- --- ------------------------------
 47103817886                     2 YES             52428800 15/02/16 16:57:01,000000000                         YES BEFORE_INSERT_DATA
insert into cmagno.teste_flashback values (1,sysdate,'LINE 1 AFTER RESTORE POINT');
 insert into cmagno.teste_flashback values (2,sysdate,'LINE 2 AFTER RESTORE POINT');
 insert into cmagno.teste_flashback values (3,sysdate,'LINE 3 AFTER RESTORE POINT');
 COMMIT;
clonetst > SELECT * FROM cmagno.teste_flashback;
NUM SYS_DATE INFO
 ---------- -------- --------------------------------------------------
 1 15/02/16 LINE 1 AFTER RESTORE POINT
 2 15/02/16 LINE 2 AFTER RESTORE POINT
 3 15/02/16 LINE 3 AFTER RESTORE POINT
SYS @ clonetst > SHUT IMMEDIATE
 Database closed.
 Database dismounted.
 ORACLE instance shut down.
 SYS @ clonetst > startup mount;
 ORACLE instance started.
Total System Global Area  588746752 bytes
 Fixed Size                  2255472 bytes
 Variable Size             369100176 bytes
 Database Buffers          209715200 bytes
 Redo Buffers                7675904 bytes
 Database mounted.
SYS @ clonetst > flashback database to restore point BEFORE_INSERT_DATA;
Flashback complete.
SYS @ clonetst > alter database open resetlogs;
Database altered.
SYS @ clonetst > SELECT * FROM cmagno.teste_flashback;
no rows selected