By Mouhamadou Diaw
The Oracle Multitenant architecture came with Oracle 12c a few years ago. For people usually working with traditional Non-CDB database it might be confusing the first time to do Backup and Recovery with pluggable databases (PDBs)
In this document we are trying to explain how to use RMAN backup and recovery in a multitenant environment for an oracle 19c database with 2 pluggable databases.
Below the configuration we are using.
|
1
2
3
4
5
6
7
|
SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1 READ WRITE NO 4 PDB2 READ WRITE NO |
We will not use a recovery catalog, but the use of recovery is the same than in a non-CDB environment.
Note that starting with Oracle 19c, we can now connect to a recovery catalog when the target database is a PDB.
Whole CDB Backups
Backin up a whole CDB is like backing up non-CDB database. We have to backup
-root pdb
-all pluggable databases
-archived logs
The steps are:
1- Connect to the root container with a common user having SYSBACKUP or SYSDBA privileges
|
1
2
3
4
5
|
RMAN> connect target /connected to target database: ORCL (DBID=1546409981)RMAN> |
2- Launch the backup
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
RMAN> BACKUP DATABASE PLUS ARCHIVELOG;Starting backup at 11-SEP-19current log archivedusing target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=279 device type=DISKchannel ORA_DISK_1: starting archived log backup setchannel ORA_DISK_1: specifying archived log(s) in backup setinput archived log thread=1 sequence=6 RECID=1 STAMP=1018632767input archived log thread=1 sequence=7 RECID=2 STAMP=1018690452input archived log thread=1 sequence=8 RECID=3 STAMP=1018691169input archived log thread=1 sequence=9 RECID=4 STAMP=1018693343channel ORA_DISK_1: starting piece 1 at 11-SEP-19channel ORA_DISK_1: finished piece 1 at 11-SEP-19piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2019_09_11/o1_mf_annnn......Finished backup at 11-SEP-19Starting Control File and SPFILE Autobackup at 11-SEP-19piece handle=/u01/app/oracle/fast_recovery_area/ORCL/autobackup/2019_09_11/o1_mf_s_1018693411_gqkcr46z_.bkp comment=NONEFinished Control File and SPFILE Autobackup at 11-SEP-19 |
Oracle also recommends to backup sometimes the root container.
Once connected to the root container with a common user, run the backup command
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
RMAN> BACKUP DATABASE ROOT;Starting backup at 11-SEP-19using channel ORA_DISK_1channel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setinput datafile file number=00001 name=/u01/app/oracle/oradata/ORCL/system01.dbfinput datafile file number=00003 name=/u01/app/oracle/oradata/ORCL/sysaux01.dbfinput datafile file number=00004 name=/u01/app/oracle/oradata/ORCL/undotbs01.dbfinput datafile file number=00007 name=/u01/app/oracle/oradata/ORCL/users01.dbfchannel ORA_DISK_1: starting piece 1 at 11-SEP-19channel ORA_DISK_1: finished piece 1 at 11-SEP-19piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2019_09_11/o1_mf_nnndf_TAG20190911T103019_gqkd4vxb_.bkp tag=TAG20190911T103019 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:16Finished backup at 11-SEP-19Starting Control File and SPFILE Autobackup at 11-SEP-19piece handle=/u01/app/oracle/fast_recovery_area/ORCL/autobackup/2019_09_11/o1_mf_s_1018693836_gqkd5d65_.bkp comment=NONEFinished Control File and SPFILE Autobackup at 11-SEP-19RMAN> |
PDBSs Backups
Backing up PDBs is not difficult, there are just some mechanisms to know. When connecting with RMAN to the root container, we can back up one or more PDBs while directly connecting to a PDB, we can only back up this PDB.
1- Connect to the root container with a common user having SYSBACKUP or SYSDBA privileges
|
1
2
3
4
5
|
RMAN> connect target /connected to target database: ORCL (DBID=1546409981)RMAN> |
And backup individual PDBs
|
1
2
3
4
5
6
7
8
9
10
11
12
|
RMAN> BACKUP PLUGGABLE DATABASE PDB1,PDB2;Starting backup at 11-SEP-19using channel ORA_DISK_1channel ORA_DISK_1: starting full datafile backup set......Starting Control File and SPFILE Autobackup at 11-SEP-19piece handle=/u01/app/oracle/fast_recovery_area/ORCL/autobackup/2019_09_11/o1_mf_s_1018695111_gqkff85l_.bkp comment=NONEFinished Control File and SPFILE Autobackup at 11-SEP-19RMAN> |
2- Connecting to the PDBs with a local user having SYSBACKUP or SYSDBA privileges
PDB1
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
RMAN> connect target sys/root@pdb1connected to target database: ORCL:PDB1 (DBID=4178439423)RMAN> BACKUP DATABASE;Starting backup at 11-SEP-19using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=279 device type=DISKchannel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setinput datafile file number=00010 name=/u01/app/oracle/oradata/ORCL/pdb1/sysaux01.dbfinput datafile file number=00009 name=/u01/app/oracle/oradata/ORCL/pdb1/system01.dbfinput datafile file number=00011 name=/u01/app/oracle/oradata/ORCL/pdb1/undotbs01.dbfinput datafile file number=00012 name=/u01/app/oracle/oradata/ORCL/pdb1/users01.dbfchannel ORA_DISK_1: starting piece 1 at 11-SEP-19channel ORA_DISK_1: finished piece 1 at 11-SEP-19piece handle=/u01/app/oracle/fast_recovery_area/ORCL/92359B0BEC8B4545E0531502A8C0F64E/backupset/2019_09_11/o1_mf_nnndf_TAG20190911T110707_gqkg9w5n_.bkp tag=TAG20190911T110707 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:07Finished backup at 11-SEP-19RMAN> |
PDB2
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
RMAN> connect target sys/root@pdb2connected to target database: ORCL:PDB2 (DBID=3996013191)RMAN> BACKUP DATABASE;Starting backup at 11-SEP-19using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=279 device type=DISKchannel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setinput datafile file number=00014 name=/u01/app/oracle/oradata/ORCL/pdb2/sysaux01.dbfinput datafile file number=00013 name=/u01/app/oracle/oradata/ORCL/pdb2/system01.dbfinput datafile file number=00015 name=/u01/app/oracle/oradata/ORCL/pdb2/undotbs01.dbfinput datafile file number=00016 name=/u01/app/oracle/oradata/ORCL/pdb2/users01.dbfchannel ORA_DISK_1: starting piece 1 at 11-SEP-19channel ORA_DISK_1: finished piece 1 at 11-SEP-19piece handle=/u01/app/oracle/fast_recovery_area/ORCL/92359E387C754644E0531502A8C02C00/backupset/2019_09_11/o1_mf_nnndf_TAG20190911T110844_gqkgdwmm_.bkp tag=TAG20190911T110844 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:07Finished backup at 11-SEP-19RMAN> |
Tablespace Backup in a PDB
Tablespaces in different PDBs can have the same name. So to eliminate ambiguity always connect to the PDB you want to back up tablespaces.
1- Connect to the PDB with a local user having SYSBACKUP or SYSDBA privilege
|
1
2
3
4
5
6
7
8
|
[oracle@oraadserver ~]$ rman target sys/root@pdb1Recovery Manager: Release 19.0.0.0.0 - Production on Wed Sep 11 11:35:53 2019Version 19.3.0.0.0Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.connected to target database: ORCL:PDB1 (DBID=4178439423) |
2- Issue the BACKUP TABLESPACE command
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
RMAN> BACKUP TABLESPACE USERS;Starting backup at 11-SEP-19using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=290 device type=DISKchannel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setinput datafile file number=00012 name=/u01/app/oracle/oradata/ORCL/pdb1/users01.dbfchannel ORA_DISK_1: starting piece 1 at 11-SEP-19channel ORA_DISK_1: finished piece 1 at 11-SEP-19piece handle=/u01/app/oracle/fast_recovery_area/ORCL/92359B0BEC8B4545E0531502A8C0F64E/backupset/2019_09_11/o1_mf_nnndf_TAG20190911T113623_gqkj0qxl_.bkp tag=TAG20190911T113623 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:01Finished backup at 11-SEP-19RMAN> |
Data File Backup in a PDB
Data Files are identified by a unique number across the CDB. So for the Backup we can connect either to the root container or directly to the PDB.
Note that while directly connecting to the PDB, we can only backup files belonging to this PDB.
1- Connect to the root container with a common user having SYSBACKUP or SYSDBA privileges
|
1
2
3
4
5
6
7
8
|
[oracle@oraadserver admin]$ rman target /Recovery Manager: Release 19.0.0.0.0 - Production on Wed Sep 11 11:54:42 2019Version 19.3.0.0.0Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.connected to target database: ORCL (DBID=1546409981) |
2- Backup the Data File
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
RMAN> BACKUP DATAFILE 10;Starting backup at 11-SEP-19using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=274 device type=DISKchannel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setinput datafile file number=00010 name=/u01/app/oracle/oradata/ORCL/pdb1/sysaux01.dbfchannel ORA_DISK_1: starting piece 1 at 11-SEP-19channel ORA_DISK_1: finished piece 1 at 11-SEP-19piece handle=/u01/app/oracle/fast_recovery_area/ORCL/92359B0BEC8B4545E0531502A8C0F64E/backupset/2019_09_11/o1_mf_nnndf_TAG20190911T115504_gqkk3s44_.bkp tag=TAG20190911T115504 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:03Finished backup at 11-SEP-19Starting Control File and SPFILE Autobackup at 11-SEP-19piece handle=/u01/app/oracle/fast_recovery_area/ORCL/autobackup/2019_09_11/o1_mf_s_1018698908_gqkk3wwt_.bkp comment=NONEFinished Control File and SPFILE Autobackup at 11-SEP-19RMAN> |
Whole CDB Complete Recovery
Suppose we lose all Data Files, Control Files and Redo Log Files of the whole container. We can restore with the following steps
1- Restore Control Files while connecting to the root container
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
[oracle@oraadserver ORCL]$ rman target /Recovery Manager: Release 19.0.0.0.0 - Production on Wed Sep 11 14:25:25 2019Version 19.3.0.0.0Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.connected to target database (not started)RMAN> startup nomountOracle instance startedTotal System Global Area 872413680 bytesFixed Size 9140720 bytesVariable Size 297795584 bytesDatabase Buffers 557842432 bytesRedo Buffers 7634944 bytesRMAN>RMAN> restore controlfile FROM AUTOBACKUP;Starting restore at 11-SEP-19using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=21 device type=DISKrecovery area destination: /u01/app/oracle/fast_recovery_areadatabase name (or database unique name) used for search: ORCLchannel ORA_DISK_1: AUTOBACKUP /u01/app/oracle/fast_recovery_area/ORCL/autobackup/2019_09_11/o1_mf_s_1018698908_gqkk3wwt_.bkp found in the recovery areaAUTOBACKUP search with format "%F" not attempted because DBID was not setchannel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/app/oracle/fast_recovery_area/ORCL/autobackup/2019_09_11/o1_mf_s_1018698908_gqkk3wwt_.bkpchannel ORA_DISK_1: control file restore from AUTOBACKUP completeoutput file name=/u01/app/oracle/oradata/ORCL/control01.ctloutput file name=/u01/app/oracle/fast_recovery_area/ORCL/control02.ctlFinished restore at 11-SEP-19RMAN> |
2- Mount the CDB
|
1
2
3
4
|
RMAN> alter database mount;released channel: ORA_DISK_1Statement processed |
3- List Backup of archived logs
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
RMAN> list backup of archivelog all;List of Backup Sets===================BS Key Size Device Type Elapsed Time Completion Time------- ---------- ----------- ------------ ---------------2 397.52M DISK 00:00:04 11-SEP-19 BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20190911T102225 Piece Name: /u01/app/oracle/fast_recovery_area/ORCL/backupset/2019_09_11/o1_mf_annnn_TAG20190911T102225_gqkcp1k9_.bkp List of Archived Logs in backup set 2 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- --------- ---------- --------- 1 6 2120330 10-SEP-19 2155559 10-SEP-19 1 7 2155559 10-SEP-19 2257139 11-SEP-19 1 8 2257139 11-SEP-19 2327294 11-SEP-19 1 9 2327294 11-SEP-19 2342937 11-SEP-19BS Key Size Device Type Elapsed Time Completion Time------- ---------- ----------- ------------ ---------------7 5.00K DISK 00:00:00 11-SEP-19 BP Key: 7 Status: AVAILABLE Compressed: NO Tag: TAG20190911T102330 Piece Name: /u01/app/oracle/fast_recovery_area/ORCL/backupset/2019_09_11/o1_mf_annnn_TAG20190911T102330_gqkcr2n1_.bkp List of Archived Logs in backup set 7 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- --------- ---------- --------- 1 10 2342937 11-SEP-19 2342996 11-SEP-19RMAN> |
4- Restore the database according to the sequence
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
RMAN> restore database until sequence 11;Starting restore at 11-SEP-19Starting implicit crosscheck backup at 11-SEP-19allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=24 device type=DISKCrosschecked 18 objects......channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:07Finished restore at 11-SEP-19RMAN> |
5- Recover the database
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
RMAN> recover database until sequence 11;Starting recover at 11-SEP-19using channel ORA_DISK_1starting media recoveryarchived log for thread 1 with sequence 10 is already on disk as file /u01/app/oracle/fast_recovery_area/ORCL/archivelog/2019_09_11/o1_mf_1_10_gqkcr27d_.arcarchived log file name=/u01/app/oracle/fast_recovery_area/ORCL/archivelog/2019_09_11/o1_mf_1_10_gqkcr27d_.arc thread=1 sequence=10media recovery complete, elapsed time: 00:00:00Finished recover at 11-SEP-19RMAN> |
6- Open database in Resetlogs mode
|
1
2
3
4
5
|
RMAN> alter database open resetlogs;Statement processedRMAN> |
PDBs Complete Recovery
To recover a PDB we can :
– Connect to the root and then use the RESTORE PLUGGABLE DATABASE and RECOVER PLUGGABLE DATABASE commands.
1- Close the PDB to recover
|
1
2
3
4
5
6
7
8
9
10
11
12
|
SQL> alter pluggable database pdb1 close;Pluggable database altered.SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1 MOUNTED 4 PDB2 READ WRITE NOSQL> |
2- Connect to rman on the root container and issue the restore command
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
RMAN> RESTORE PLUGGABLE DATABASE PDB1;Starting restore at 11-SEP-19using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=56 device type=DISKchannel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00009 to /u01/app/oracle/oradata/ORCL/pdb1/system01.dbfchannel ORA_DISK_1: restoring datafile 00010 to /u01/app/oracle/oradata/ORCL/pdb1/sysaux01.dbfchannel ORA_DISK_1: restoring datafile 00011 to /u01/app/oracle/oradata/ORCL/pdb1/undotbs01.dbfchannel ORA_DISK_1: restoring datafile 00012 to /u01/app/oracle/oradata/ORCL/pdb1/users01.dbfchannel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/ORCL/92359B0BEC8B4545E0531502A8C0F64E/backupset/2019_09_11/o1_mf_nnndf_TAG20190911T144816_gqkv9btm_.bkpchannel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ORCL/92359B0BEC8B4545E0531502A8C0F64E/backupset/2019_09_11/o1_mf_nnndf_TAG20190911T144816_gqkv9btm_.bkp tag=TAG20190911T144816channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:07Finished restore at 11-SEP-19 |
3- Recover the pluggable database
|
1
2
3
4
5
6
7
8
9
|
RMAN> RECOVER PLUGGABLE DATABASE PDB1;Starting recover at 11-SEP-19using channel ORA_DISK_1starting media recoverymedia recovery complete, elapsed time: 00:00:01Finished recover at 11-SEP-19 |
4- Open the pluggable database
|
1
2
3
4
5
|
RMAN> alter pluggable database PDB1 open;Statement processedRMAN> |
– Connect to the PDB and use the RESTORE DATABASE and RECOVER DATABASE commands.
1- Close the PDB to recover
|
1
2
3
4
5
6
7
8
|
SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1 READ WRITE NO 4 PDB2 MOUNTEDSQL> |
2- Connect to the PDB and issue the RESTORE DATABASE command
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
[oracle@oraadserver pdb1]$ rman target sys/root@pdb2Recovery Manager: Release 19.0.0.0.0 - Production on Wed Sep 11 15:19:03 2019Version 19.3.0.0.0Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.connected to target database: ORCL:PDB2 (DBID=3996013191, not open)RMAN> RESTORE DATABASE;Starting restore at 11-SEP-19using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=45 device type=DISKchannel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00013 to /u01/app/oracle/oradata/ORCL/pdb2/system01.dbfchannel ORA_DISK_1: restoring datafile 00014 to /u01/app/oracle/oradata/ORCL/pdb2/sysaux01.dbfchannel ORA_DISK_1: restoring datafile 00015 to /u01/app/oracle/oradata/ORCL/pdb2/undotbs01.dbfchannel ORA_DISK_1: restoring datafile 00016 to /u01/app/oracle/oradata/ORCL/pdb2/users01.dbfchannel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/ORCL/92359E387C754644E0531502A8C02C00/backupset/2019_09_11/o1_mf_nnndf_TAG20190911T144816_gqkv9tfq_.bkpchannel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ORCL/92359E387C754644E0531502A8C02C00/backupset/2019_09_11/o1_mf_nnndf_TAG20190911T144816_gqkv9tfq_.bkp tag=TAG20190911T144816channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:07Finished restore at 11-SEP-19RMAN> |
3- Recover the pluggable database
|
1
2
3
4
5
6
7
8
9
|
RMAN> recover database;Starting recover at 11-SEP-19using channel ORA_DISK_1starting media recoverymedia recovery complete, elapsed time: 00:00:01Finished recover at 11-SEP-19 |
4- Open the database
|
1
2
3
4
5
|
RMAN> alter database open ;Statement processedRMAN> |
Complete Tablespace Recovery in a PDB
-Non-SYSTEM Tablespace
To recover a Non-SYSTEM Tablespace in a PDB we can do next steps
1-Put the tablespace offline while connecting to the PDB
|
1
2
3
4
5
|
SQL> ALTER TABLESPACE MYTAB OFFLINE;Tablespace altered.SQL> |
2- Connect to the PDB with RMAN and issue the RESTORE TABLESPACE command
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
[oracle@oraadserver pdb2]$ rman target sys/root@pdb2Recovery Manager: Release 19.0.0.0.0 - Production on Wed Sep 11 16:52:37 2019Version 19.3.0.0.0Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.connected to target database: ORCL:PDB2 (DBID=3996013191)RMAN> RESTORE TABLESPACE MYTAB;Starting restore at 11-SEP-19using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=274 device type=DISKchannel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00017 to /u01/app/oracle/oradata/ORCL/pdb2/mytab01.dbfchannel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/ORCL/92359E387C754644E0531502A8C02C00/backupset/2019_09_11/o1_mf_nnndf_TAG20190911T163708_gql1o4gx_.bkpchannel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ORCL/92359E387C754644E0531502A8C02C00/backupset/2019_09_11/o1_mf_nnndf_TAG20190911T163708_gql1o4gx_.bkp tag=TAG20190911T163708channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:01Finished restore at 11-SEP-19 |
3- Issue the RECOVER TABLESPACE command
|
1
2
3
4
5
6
7
8
9
10
11
|
RMAN> RECOVER TABLESPACE MYTAB;Starting recover at 11-SEP-19using channel ORA_DISK_1starting media recoverymedia recovery complete, elapsed time: 00:00:01Finished recover at 11-SEP-19RMAN> |
4- Put back the tablespace ONLINE
|
1
2
3
4
5
|
RMAN> ALTER TABLESPACE MYTAB ONLINE;Statement processedRMAN> |
-SYSTEM Tablespace
To recover a SYSTEM Tablespace in a PDB
1- Shutdown the entire CDB and Mount it
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
[oracle@oraadserver pdb2]$ sqlplus / as sysdbaSQL*Plus: Release 19.0.0.0.0 - Production on Wed Sep 11 17:09:33 2019Version 19.3.0.0.0Copyright (c) 1982, 2019, Oracle. All rights reserved.Connected to:Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - ProductionVersion 19.3.0.0.0SQL> shut immediateORA-01116: error in opening database file 13ORA-01110: data file 13: '/u01/app/oracle/oradata/ORCL/pdb2/system01.dbf'ORA-27041: unable to open fileLinux-x86_64 Error: 2: No such file or directoryAdditional information: 3SQL> shut abort;ORACLE instance shut down.SQL>SQL> startup mountORACLE instance started.Total System Global Area 872413680 bytesFixed Size 9140720 bytesVariable Size 310378496 bytesDatabase Buffers 545259520 bytesRedo Buffers 7634944 bytesDatabase mounted.SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED---------- ------------------------------ ---------- ---------- 2 PDB$SEED MOUNTED 3 PDB1 MOUNTED 4 PDB2 MOUNTEDSQL> |
2- Connect to root container and restore the corresponding files (Files can be identified using command REPORT SCHEMA for example)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
RMAN> RESTORE DATAFILE 13;Starting restore at 11-SEP-19allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=26 device type=DISKchannel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00013 to /u01/app/oracle/oradata/ORCL/pdb2/system01.dbfchannel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/ORCL/92359E387C754644E0531502A8C02C00/backupset/2019_09_11/o1_mf_nnndf_TAG20190911T163708_gql1o4gx_.bkpchannel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ORCL/92359E387C754644E0531502A8C02C00/backupset/2019_09_11/o1_mf_nnndf_TAG20190911T163708_gql1o4gx_.bkp tag=TAG20190911T163708channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:03Finished restore at 11-SEP-19RMAN> |
3- Recover the Data File
|
1
2
3
4
5
6
7
8
9
|
RMAN> RECOVER DATAFILE 13;Starting recover at 11-SEP-19using channel ORA_DISK_1starting media recoverymedia recovery complete, elapsed time: 00:00:00Finished recover at 11-SEP-19 |
4- Open all containers
|
1
2
3
4
5
6
7
8
9
|
RMAN> alter database open;Statement processedRMAN> ALTER PLUGGABLE DATABASE ALL OPEN READ WRITE;Statement processedRMAN> |
Conclusion
In this blog we basically explain how to use RMAN in a multitenant environment. We did not talked about PITR recovery, we will do it in a coming blog.
Note also that we did not use RMAN commands like LIST FAILURE, ADVISE FAILURE and REPAIR FAILURE. But these commands also work.
Eric Simbozel
12.09.2023Hello Docteur, quel est l'intérêt de backuper une pluggable database plutôt que le container ?
Clemens Bleile
17.09.2023Hello Eric,
to your question on what the purpose is to backup PDBs instead of the whole CDB:
There are several situations where PDB-backups are useful. E.g.
- You plugin a non-CDB or plugin a PDB from another CDB and want to keep the backup history.
- A pluggable DB administrator can do a backup of his PDB himself.
We do recommend to backup the whole CDB to be able to do full restores of the CDB or parts of it, but as you can see above, there are situations when backing up one or more PDBs can be very handy as well.
Regards
Clemens