Search This Blog

Tuesday, November 1, 2022

Restoring single Pluggable database (PDB ) to different server from CDB backup

 














In this post , we will see how we can restore a single Pluggable database to a new server from the CDB backup without need to restore the complete CDB.

Source Environment setup :


RAC Database          : VO19CDB (vo19cdb1 and vo19cdb2)
GRID Home                 : /u01/app/19.3.0.0/grid
RDBMS Home : /u01/app/oracle/product/19.14.0.0/dbhome_1
Version                         : Oracle Database 19c EE - Production Version 19.14.0.0.0
hosts          : sourceh01


Target Environment setup :


RAC Database          : VO19CDB (vo19cdb1 and vo19cdb2)
GRID Home                 : /u01/app/19.3.0.0/grid
RDBMS Home : /u01/app/oracle/product/19.3.0.0/dbhome_1
Version                         : Oracle Database 19c EE - Production Version 19.14.0.0.0
hosts          : cdbhost01 & cdbhost02

We have three PDBs in the CDB, VOL19CDB running on sourceh01 database server.  


 





In this exercise , we will try to take backup of this CDB and then restore one pluggable database (PDB2) on new server.

For this, I referred the below metalink document, 
How to use Rman to Restore Of Single PDB in Multitenant to Alternate Server (Doc ID 2142675.1)


Step 1)  Create a Test table in pluggable database, PDB2

[oracle@sourceh01 VO19CDB]$ sqlplus pdb2user/welcome@pdb2

SQL*Plus: Release 19.0.0.0.0 - Production on Thu Oct 27 10:00:57 2022 Version 19.14.0.0.0

Copyright (c) 1982, 2021, Oracle.  All rights reserved.

Last Successful login time: Thu Oct 27 2022 08:29:45 -05:00

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.14.0.0.0

SQL>  create table PDB2TEST1_Before_backup (name varchar2(50));
Table created.

SQL> insert into PDB2TEST1_Before_backup values ('this table is created before rman backup');
1 row created.

SQL> commit;
Commit complete.

SQL> SQL> select * from PDB2TEST1_BEFORE_BACKUP;

NAME
--------------------------------------------------
this table is created before rman backup
SQL> exit

Step 2)  Take a backup of the source database, VO19CDB running on server, source01

Take RMAN backup of the source CDB database using below command.

RMAN  >
run
{
allocate channel ch1 device type disk format '/u01/software/backup/VO19CDB/DATA_L0_%d_%Y%M%D_%s-%p-%t';
backup incremental level 0 database plus archivelog TAG='FULL_BACKUP_B4_UPGRADE' format '/u01/software/backup/VO19CDB/DATA_L0_%d_%Y%M%D_%s-%p-%t';
backup tag 'CONTROL_BACKUP' current controlfile format '/u01/software/backup/VO19CDB/DATA_CONTROL_%d_%Y%M%D_%s-%p-%t';
release channel ch1;
}

Take the backup now.

[oracle@19cracp1 VO19CDB]$ rman target / catalog=rman_catalog/welcome@rmancat
Recovery Manager: Release 19.0.0.0.0 - Production on Thu Oct 27 10:10:45 2022
Version 19.14.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database: VO19CDB (DBID=297364323)
connected to recovery catalog database

RMAN>
run
{
allocate channel ch1 device type disk format '/u01/software/backup/VO19CDB/DATA_L0_%d_%Y%M%D_%s-%p-%t';
backup incremental level 0 database plus archivelog TAG='FULL_BACKUP_B4_UPGRADE' format '/u01/software/backup/VO19CDB/DATA_L0_%d_%Y%M%D_%s-%p-%t';backup tag 'CONTROL_BACKUP' current controlfile format '/u01/software/backup/VO19CDB/DATA_CONTROL_%d_%Y%M%D_%s-%p-%t';

release channel ch1;

}2> 3> 4> 5> 6> 7>

allocated channel: ch1
channel ch1: SID=127 instance=vo19cdb1 device type=DISK
Starting backup at 27-OCT-22
current log archived
channel ch1: starting archived log backup set
channel ch1: specifying archived log(s) in backup set
input archived log thread=1 sequence=12 RECID=1 STAMP=1119118027
input archived log thread=1 sequence=13 RECID=2 STAMP=1119124521
input archived log thread=1 sequence=14 RECID=3 STAMP=1119124528
input archived log thread=1 sequence=15 RECID=4 STAMP=1119124557
input archived log thread=1 sequence=16 RECID=5 STAMP=1119137563
input archived log thread=1 sequence=17 RECID=6 STAMP=1119139381
input archived log thread=1 sequence=18 RECID=7 STAMP=1119139768
input archived log thread=1 sequence=19 RECID=8 STAMP=1119175830
input archived log thread=1 sequence=20 RECID=9 STAMP=1119175854
channel ch1: starting piece 1 at 27-OCT-22
channel ch1: finished piece 1 at 27-OCT-22
piece handle=/u01/software/backup/VO19CDB/DATA_L0_VO19CDB_20221027_12-1-1119175854 tag=FULL_BACKUP_B4_UPGRADE comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:03
Finished backup at 27-OCT-22
Starting backup at 27-OCT-22
channel ch1: starting incremental level 0 datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA/VO19CDB/DATAFILE/system.338.1119116399
input datafile file number=00003 name=+DATA/VO19CDB/DATAFILE/sysaux.339.1119116433
input datafile file number=00004 name=+DATA/VO19CDB/DATAFILE/undotbs1.340.1119116459
input datafile file number=00007 name=+DATA/VO19CDB/DATAFILE/users.341.1119116461
channel ch1: starting piece 1 at 27-OCT-22
channel ch1: finished piece 1 at 27-OCT-22
piece handle=/u01/software/backup/VO19CDB/DATA_L0_VO19CDB_20221027_13-1-1119175858 tag=TAG20221027T101058 comment=NONE

channel ch1: backup set complete, elapsed time: 00:00:07
channel ch1: starting incremental level 0 datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00021 name=+DATA/VO19CDB/EBF91570AE644E62E053011478C064A9/DATAFILE/pdb2_tst.374.1119123985
input datafile file number=00014 name=+DATA/VO19CDB/EBF91570AE644E62E053011478C064A9/DATAFILE/sysaux.365.1119118029
input datafile file number=00013 name=+DATA/VO19CDB/EBF91570AE644E62E053011478C064A9/DATAFILE/system.364.1119118029
input datafile file number=00015 name=+DATA/VO19CDB/EBF91570AE644E62E053011478C064A9/DATAFILE/undotbs1.363.1119118029
input datafile file number=00016 name=+DATA/VO19CDB/EBF91570AE644E62E053011478C064A9/DATAFILE/users.367.1119118045

channel ch1: starting piece 1 at 27-OCT-22
channel ch1: finished piece 1 at 27-OCT-22
piece handle=/u01/software/backup/VO19CDB/DATA_L0_VO19CDB_20221027_14-1-1119175865 tag=TAG20221027T101058 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:03

channel ch1: starting incremental level 0 datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00010 name=+DATA/VO19CDB/EBF913C2D5CB4C02E053011478C0AC21/DATAFILE/sysaux.359.1119118001
input datafile file number=00009
ame=+DATA/VO19CDB/EBF913C2D5CB4C02E053011478C0AC21/DATAFILE/system.358.1119118001
input datafile file number=00011 name=+DATA/VO19CDB/EBF913C2D5CB4C02E053011478C0AC21/DATAFILE/undotbs1.357.1119118001
input datafile file number=00012 name=+DATA/VO19CDB/EBF913C2D5CB4C02E053011478C0AC21/DATAFILE/users.361.1119118025
channel ch1: starting piece 1 at 27-OCT-22
channel ch1: finished piece 1 at 27-OCT-22

piece handle=/u01/software/backup/VO19CDB/DATA_L0_VO19CDB_20221027_15-1-1119175869 tag=TAG20221027T101058 comment=NONE

channel ch1: backup set complete, elapsed time: 00:00:03
channel ch1: starting incremental level 0 datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00018 name=+DATA/VO19CDB/EBF91676C2FC4FF5E053011478C0BA1C/DATAFILE/sysaux.370.1119118045
input datafile file number=00017 name=+DATA/VO19CDB/EBF91676C2FC4FF5E053011478C0BA1C/DATAFILE/system.369.1119118045
input datafile file number=00019 name=+DATA/VO19CDB/EBF91676C2FC4FF5E053011478C0BA1C/DATAFILE/undotbs1.368.1119118045
input datafile file number=00020 name=+DATA/VO19CDB/EBF91676C2FC4FF5E053011478C0BA1C/DATAFILE/users.372.1119118061
channel ch1: starting piece 1 at 27-OCT-22
channel ch1: finished piece 1 at 27-OCT-22
piece handle=/u01/software/backup/VO19CDB/DATA_L0_VO19CDB_20221027_16-1-1119175872 tag=TAG20221027T101058 comment=NONE

channel ch1: backup set complete, elapsed time: 00:00:03
channel ch1: starting incremental level 0 datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00006 name=+DATA/VO19CDB/86B637B62FE07A65E053F706E80A27CA/DATAFILE/sysaux.352.1119117179
input datafile file number=00005 name=+DATA/VO19CDB/86B637B62FE07A65E053F706E80A27CA/DATAFILE/system.351.1119117179
input datafile file number=00008 name=+DATA/VO19CDB/86B637B62FE07A65E053F706E80A27CA/DATAFILE/undotbs1.353.1119117179
channel ch1: starting piece 1 at 27-OCT-22
channel ch1: finished piece 1 at 27-OCT-22
piece handle=/u01/software/backup/VO19CDB/DATA_L0_VO19CDB_20221027_17-1-1119175875 tag=TAG20221027T101058 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:07

Finished backup at 27-OCT-22
Starting backup at 27-OCT-22
current log archived
channel ch1: starting archived log backup set
channel ch1: specifying archived log(s) in backup set

input archived log thread=1 sequence=21 RECID=10 STAMP=1119175882

channel ch1: starting piece 1 at 27-OCT-22
channel ch1: finished piece 1 at 27-OCT-22
piece handle=/u01/software/backup/VO19CDB/DATA_L0_VO19CDB_20221027_18-1-1119175883 tag=FULL_BACKUP_B4_UPGRADE comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:01

Finished backup at 27-OCT-22
Starting backup at 27-OCT-22
channel ch1: starting full datafile backup set
channel ch1: specifying datafile(s) in backup set
including current control file in backup set
channel ch1: starting piece 1 at 27-OCT-22
channel ch1: finished piece 1 at 27-OCT-22
piece handle=/u01/software/backup/VO19CDB/DATA_CONTROL_VO19CDB_20221027_19-1-1119175884 tag=CONTROL_BACKUP comment=NONE

channel ch1: backup set complete, elapsed time: 00:00:01
Finished backup at 27-OCT-22
Starting Control File and SPFILE Autobackup at 27-OCT-22
piece handle=+DATA/VO19CDB/AUTOBACKUP/2022_10_27/s_1119175887.406.1119175887 comment=NONE
Finished Control File and SPFILE Autobackup at 27-OCT-22

released channel: ch1
RMAN>


Step 3 ) Copy the backup pieces and few archive logs to the target database server.

using scp command, copy the backup files to the target server.

Below are the copied backup files and few archive logs that generated around that time





Step 4.) On the target database server, start a new instance with the same CDB name as its on the source database server.

4a) - Start the target instance in NOMOUNT state.

Using a temporary pfile , create and start the target instance in NOMOUNT stage. In this case, I am using below pfile for the new database.

[oracle@gdshol-p1 dbs]$ cat initvo19cdb1.ora
*.audit_file_dest='/u01/app/oracle/admin/vo19cdb/adump'
*.audit_trail='db'
*.cluster_database=true
*.compatible='19.0.0'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_name='vo19cdb'
*.db_recovery_file_dest='+DATA'
*.db_recovery_file_dest_size=17208m
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=vo19cdbXDB)'
*.enable_pluggable_database=true
family:dw_helper.instance_mode='read-only'
vo19cdb1.instance_number=1
*.local_listener='-oraagent-dummy-'
*.log_archive_format='%t_%s_%r.dbf'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.pga_aggregate_target=943m
*.processes=300
*.remote_login_passwordfile='exclusive'
*.sga_target=2829m
vo19cdb1.thread=1
vo19cdb1.undo_tablespace='UNDOTBS1'
max_pdbs=3

[oracle@gdshol-p1 dbs]$ 

Start the database in NOMOUNT stage

[oracle@gdshol-p1 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Nov 1 10:21:10 2022
Version 19.14.0.0.0

Copyright (c) 1982, 2022, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup nomount pfile='/u01/app/oracle/product/19.3.0.0/dbhome_1/dbs/initvo19cdb1.ora';

ORACLE instance started.
Total System Global Area 2969564184 bytes
Fixed Size                  9139224 bytes
Variable Size             671088640 bytes
Database Buffers         2281701376 bytes
Redo Buffers                7634944 bytes
SQL>

----------------------------------------------------------------------------------------------

4b) - Restore the controlfile from the backup which we took in our earlier step.

[oracle@gdshol-p1 dbs]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Tue Nov 1 10:23:08 2022
Version 19.17.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database: VO19CDB (not mounted)

RMAN> restore controlfile from '/u01/software/backup/VO19CDB/DATA_CONTROL_VO19CDB_20221027_19-1-1119175884';

Starting restore at 01-NOV-22
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=60 instance=vo19cdb1 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=+DATA/VO19CDB/CONTROLFILE/current.286.1119608591
output file name=+DATA/VO19CDB/CONTROLFILE/current.287.1119608591

Finished restore at 01-NOV-22
RMAN>

----------------------------------------------------------------------------------------------------

4c) - Add the control file info to the pfile and create a spfile with the updated pfile

[oracle@gdshol-p1 dbs]$ cp  initvo19cdb1.ora initvo19cdb1.ora.orig
[oracle@gdshol-p1 dbs]$ vi initvo19cdb1.ora
[oracle@gdshol-p1 dbs]$ cat initvo19cdb1.ora
*.audit_file_dest='/u01/app/oracle/admin/vo19cdb/adump'
*.audit_trail='db'
*.cluster_database=true
*.compatible='19.0.0'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_name='vo19cdb'
*.db_recovery_file_dest='+DATA'
*.control_files='+DATA/VO19CDB/CONTROLFILE/current.286.1119608591','+DATA/VO19CDB/CONTROLFILE/current.287.1119608591'
*.db_recovery_file_dest_size=17208m
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=vo19cdbXDB)'
*.enable_pluggable_database=true
family:dw_helper.instance_mode='read-only'
vo19cdb1.instance_number=1
*.local_listener='-oraagent-dummy-'
*.log_archive_format='%t_%s_%r.dbf'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.pga_aggregate_target=943m
*.processes=300
*.remote_login_passwordfile='exclusive'
*.sga_target=2829m
vo19cdb1.thread=1
vo19cdb1.undo_tablespace='UNDOTBS1'
max_pdbs=3


Create spfile from the above pfile.

oracle@cdbhost01 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Nov 1 10:28:05 2022
Version 19.14.0.0.0

Copyright (c) 1982, 2022, Oracle.  All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.14.0.0.0
SQL> create spfile='+DATA/VO19CDB/PARAMETERFILE/spfilevo19cdb.ora' from pfile='/u01/app/oracle/product/19.3.0.0/dbhome_1/dbs/initvo19cdb1.ora';

File created.
SQL>

Add the spfile info in the pfile 

[oracle@cdbhost01 dbs]$ mv initvo19cdb1.ora initvo19cdb1.ora.orig
[oracle@cdbhost01 dbs]$ vi initvo19cdb1.ora
[oracle@cdbhost01 dbs]$ cat initvo19cdb1.ora
spfile='+DATA/VO19CDB/PARAMETERFILE/spfilevo19cdb.ora'
[oracle@gdshol-p1 dbs]$

Now shutdown the database and start the database in MOUNT stage using the updated pfile.

 oracle@cdbhost01 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Nov 1 10:28:05 2022
Version 19.14.0.0.0
Copyright (c) 1982, 2022, Oracle.  All rights reserved.
Connected to
SQL > shut immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL>


Step 5 ) Start the database in MOUNT mode 

[oracle@cdbhost01 dbs]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Tue Nov 1 10:31:35 2022
Version 19.14.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

RMAN> startup mount
Oracle instance started
database mounted

Total System Global Area    2969564184 bytes
Fixed Size                     9139224 bytes
Variable Size                671088640 bytes
Database Buffers            2281701376 bytes
Redo Buffers                   7634944 bytes
RMAN>

Step 6) perform the database restore using below RMAN command

RMAN command :

run
{
  set until time "TO_DATE('27-OCT-2022 10:12:00','DD-MON-YYYY HH24:MI:SS')";
  restore database root ; 
  restore database "PDB$SEED"; 
  restore database PDB2;   
}

Perform the database restore.

oracle@gdshol-p1 dbs]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Tue Nov 1 10:31:35 2022
Version 19.17.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)
RMAN> run
{
  set until time "TO_DATE('27-OCT-2022 10:12:00','DD-MON-YYYY HH24:MI:SS')";
  restore database root ;
  restore database "PDB$SEED";
  restore database PDB2;
}
executing command: SET until clause
Starting restore at 01-NOV-22
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 datafile 00001 to
DATA/VO19CDB/DATAFILE/system.338.1119116399
channel ORA_DISK_1: restoring datafile 00003 to +DATA/VO19CDB/DATAFILE/sysaux.339.1119116433
channel ORA_DISK_1: restoring datafile 00004 to +DATA/VO19CDB/DATAFILE/undotbs1.340.1119116459
channel ORA_DISK_1: restoring datafile 00007 to +DATA/VO19CDB/DATAFILE/users.341.1119116461
channel ORA_DISK_1: reading from backup piece /u01/software/backup/VO19CDB/DATA_L0_VO19CDB_20221027_13-1-1119175858

channel ORA_DISK_1: piece handle=/u01/software/backup/VO19CDB/DATA_L0_VO19CDB_20221027_13-1-1119175858 tag=TAG20221027T101058
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 01-NOV-22
Starting restore at 01-NOV-22
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 setchannel ORA_DISK_1: restoring datafile 00005 to +DATA/VO19CDB/86B637B62FE07A65E053F706E80A27CA/DATAFILE/system.351.1119117179
channel ORA_DISK_1: restoring datafile 00006 to +DATA/VO19CDB/86B637B62FE07A65E053F706E80A27CA/DATAFILE/sysaux.352.1119117179
channel ORA_DISK_1: restoring datafile 00008 to +DATA/VO19CDB/86B637B62FE07A65E053F706E80A27CA/DATAFILE/undotbs1.353.1119117179
channel ORA_DISK_1: reading from backup piece /u01/software/backup/VO19CDB/DATA_L0_VO19CDB_20221027_17-1-1119175875channel ORA_DISK_1: piece handle=/u01/software/backup/VO19CDB/DATA_L0_VO19CDB_20221027_17-1-1119175875 tag=TAG20221027T101058

channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 01-NOV-22
Starting restore at 01-NOV-22
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 datafile 00013 to +DATA/VO19CDB/EBF91570AE644E62E053011478C064A9/DATAFILE/system.364.1119118029
channel ORA_DISK_1: restoring datafile 00014 to +DATA/VO19CDB/EBF91570AE644E62E053011478C064A9/DATAFILE/sysaux.365.1119118029
channel ORA_DISK_1: restoring datafile 00015 to +DATA/VO19CDB/EBF91570AE644E62E053011478C064A9/DATAFILE/undotbs1.363.1119118029
channel ORA_DISK_1: restoring datafile 00016 to +DATA/VO19CDB/EBF91570AE644E62E053011478C064A9/DATAFILE/users.367.1119118045
channel ORA_DISK_1: restoring datafile 00021 to +DATA/VO19CDB/EBF91570AE644E62E053011478C064A9/DATAFILE/pdb2_tst.374.1119123985
channel ORA_DISK_1: reading from backup piece /u01/software/backup/VO19CDB/DATA_L0_VO19CDB_20221027_14-1-1119175865

channel ORA_DISK_1: piece handle=/u01/software/backup/VO19CDB/DATA_L0_VO19CDB_20221027_14-1-1119175865 tag=TAG20221027T101058
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07

Finished restore at 01-NOV-22
RMAN>

---------------------------------------------------------------------------------------------------

Step 7) After the database restore completes, we need to perform the recover of the the required PDB(which we are trying to restore) excluding other PDBs.

Below is the RMAN command used for this purpose.

run
{
 set until time "TO_DATE('27-OCT-2022 10:12:00','DD-MON-YYYY HH24:MI:SS')";
 recover database skip forever tablespace PDB1:SYSTEM,PDB1:SYSAUX,PDB1:USERS,PDB1:undotbs1,PDB3:SYSTEM,PDB3:SYSAUX,PDB3:USERS,PDB3:undotbs1 ;
}

As you can see from above, we are exluding all the tablespaces of other two pdbs, PDB1 and PDB3.  Only PDB2 will be recovered.

First,  lets catalog the archive logs that we copied from source database server.

RMAN> catalog start with '/u01/software/backup/VO19CDB/thread_1';

searching for all files that match the pattern /u01/software/backup/VO19CDB/thread_1
List of Files Unknown to the Database
=====================================
File Name: /u01/software/backup/VO19CDB/thread_1_seq_17.382.1119139379
File Name: /u01/software/backup/VO19CDB/thread_1_seq_18.383.1119139767
File Name: /u01/software/backup/VO19CDB/thread_1_seq_19.403.1119175829
File Name: /u01/software/backup/VO19CDB/thread_1_seq_20.404.1119175855
File Name: /u01/software/backup/VO19CDB/thread_1_seq_21.405.1119175883
File Name: /u01/software/backup/VO19CDB/thread_1_seq_22.407.1119176957
File Name: /u01/software/backup/VO19CDB/thread_1_seq_23.410.1119261339
File Name: /u01/software/backup/VO19CDB/thread_1_seq_24.431.1119295109

Do you really want to catalog the above files (enter YES or NO)? YES
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/software/backup/VO19CDB/thread_1_seq_17.382.1119139379
File Name: /u01/software/backup/VO19CDB/thread_1_seq_18.383.1119139767
File Name: /u01/software/backup/VO19CDB/thread_1_seq_19.403.1119175829
File Name: /u01/software/backup/VO19CDB/thread_1_seq_20.404.1119175855
File Name: /u01/software/backup/VO19CDB/thread_1_seq_21.405.1119175883
File Name: /u01/software/backup/VO19CDB/thread_1_seq_22.407.1119176957
File Name: /u01/software/backup/VO19CDB/thread_1_seq_23.410.1119261339
File Name: /u01/software/backup/VO19CDB/thread_1_seq_24.431.1119295109

RMAN>

Now perform the recovery operation using the RMAN command.

RMAN> run

{
  set until time "TO_DATE('27-OCT-2022 10:12:00','DD-MON-YYYY HH24:MI:SS')";
  recover database skip forever tablespace PDB1:SYSTEM,PDB1:SYSAUX,PDB1:USERS,PDB1:undotbs1,PDB3:SYSTEM,PDB3:SYSAUX,PDB3:USERS,PDB3:undotbs1 ;
}2> 3> 4> 5>

executing command: SET until clause
Starting recover at 01-NOV-22
using channel ORA_DISK_1

Executing: alter database datafile 9, 10, 11, 12 offline drop
Executing: alter database datafile 17, 18, 19, 20 offline drop
starting media recovery
archived log for thread 1 with sequence 21 is already on disk as file /u01/software/backup/VO19CDB/thread_1_seq_21.405.1119175883
archived log for thread 1 with sequence 22 is already on disk as file /u01/software/backup/VO19CDB/thread_1_seq_22.407.1119176957
archived log file name=/u01/software/backup/VO19CDB/thread_1_seq_21.405.1119175883 thread=1 sequence=21
archived log file name=/u01/software/backup/VO19CDB/thread_1_seq_22.407.1119176957 thread=1 sequence=22
media recovery complete, elapsed time: 00:00:00
Finished recover at 01-NOV-22
RMAN>

----------------------------------------------------------------------------------------------------

Step 8)  Open the database with resetlogs and open the PDB2 in read write mode.


[oracle@gdshol-p1 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Nov 1 12:17:56 2022
Version 19.17.0.0.0
Copyright (c) 1982, 2022, Oracle.  All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.17.0.0.0

SQL> alter database open retlogs;
Database altered


SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
--------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           MOUNTED
         4 PDB2                           MOUNTED
         5 PDB3                           MOUNTED
SQL> alter pluggable database PDB2 open;
Pluggable database altered.

Step 9 ) Verify if the PDB2 has the test table with the inserted row.

SQL> alter session set container= PDB2;
Session altered.

SQL> select owner,table_name from dba_tables where table_name like 'PDB2%';

OWNER             TABLE_NAME
--------------         -------------------------------------------------------------------------------
PDB2USER       PDB2TEST1_BEFORE_BACKUP

QL> select * from PDB2USER.PDB2TEST1_BEFORE_BACKUP;

NAME
------------------------------------------------
this table is created before rman backup
SQL>


and that's it, we were able to restore specific PDB from the CDB backup to a specific time.


Hope this steps helps if you have similar requirement.

Thanks
Sambaiah Sammeta



No comments:

Post a Comment