I will explain how to perform backup and restore operations in Oracle Container database.
We check if the database is in archive mode.
1 2 3 4 5 |
$ sqlplus / as sysdba SQL> select log_mode from v$database; LOG_MODE --------------- NOARCHIVELOG |
The database is not in archive mode, we connect to CDB and put it in archive mode as follows.
1 2 3 4 5 6 7 8 9 |
$ sqlplus / as sysdba SQL> shutdown immediate; SQL> startup mount; SQL> alter database archivelog; SQL> alter database open; SQL> select log_mode from v$database; LOG_MODE --------------- ARCHIVELOG |
CDB BACKUP — RESTORE
We can get CDB backup as follows. When the CDB backup is taken, the backup of all PDBs found in it is also taken.
1 2 |
$ rman target/ RMAN> BACKUP DATABASE PLUS ARCHIVELOG; |
We restore the taken backup as follows.
1 2 3 4 5 6 7 8 |
$ rman target/ RMAN> RUN { SHUTDOWN IMMEDIATE; STARTUP MOUNT; RESTORE DATABASE; RECOVER DATABASE; ALTER DATABASE OPEN; } |
PDB BACKUP — RESTORE
We can take the backup of the CRM database as follows.
1 2 |
$ rman target/ RMAN> BACKUP PLUGGABLE DATABASE CRM; |
Taking multiple PDB backups at the same time (HR and CRM):
1 2 |
$ rman target/ RMAN> BACKUP PLUGGABLE DATABASE CRM, HR; |
We restore the backup of the received CRM database as follows.
1 2 3 4 5 6 7 |
$ rman target/ RMAN> RUN { ALTER PLUGGABLE DATABASE CRM CLOSE; RESTORE PLUGGABLE DATABASE CRM; RECOVER PLUGGABLE DATABASE CRM; ALTER PLUGGABLE DATABASE CRM OPEN; } |
Tablespace Backup — Restore
We take a backup of the TEST_TS tablespace in the CRM database as follows.
1 2 |
$ rman target / RMAN> BACKUP TABLESPACE CRM:TEST_TS; |
We restore the taken backup as follows.
1 2 3 4 5 6 7 |
$ rman target sys@CRM RMAN> RUN { ALTER TABLESPACE TEST_TS OFFLINE; RESTORE TABLESPACE TEST_TS; RECOVER TABLESPACE TEST_TS; ALTER TABLESPACE TEST_TS ONLINE; } |