Suppose you’re connected to the root container as SYS and want to back up all data files (including any data files with associated pluggable databases). First, verify that you are indeed connected to the root container as SYS:
RMAN> SELECT SYS_CONTEXT('USERENV', 'CON_ID') AS con_id,
SYS_CONTEXT('USERENV', 'CON_NAME') AS cur_container,
SYS_CONTEXT('USERENV', 'CURRENT_SCHEMA') AS cur_user
FROM DUAL;
Here is some sample output:
CON_ID CUR_CONTAINER CUR_USER
-------------------- -------------------- --------------------
1 CDB$ROOT SYS
Now, to back up all data files, both in the root container and in any associated pluggable databases, do so as follows:
RMAN> backup database;
If you want to back up only the data files associated with the root container, then specify ROOT:
RMAN> backup database root;
You can also back up a specific pluggable database:
RMAN> backup pluggable database salespdb;
Additionally, you can back up specific tablespaces within a pluggable database:
RMAN> backup tablespace SALESPDB:SALES;
And, you can specify the file name to back up any data file within the root container or associated pluggable databases:
RMAN> backup datafile '/ora01/app/oracle/oradata/CDB/salespdb/sales01.dbf';