All technological notes.
Whole Database Backup and Partial Database BackupWhole Database Backup and Partial Database Backup
Whole Database BackupWhole Database Backup:
data files and the control file.PDBs datafiles and CDB root files.Prerequisites
Steps:
RMAN and connect to the target database.BACKUP command
| Command | Backup Description | Storage |
|---|---|---|
BACKUP DATABASE; |
DF, CF | backup set |
BACKUP COPY OF DATABASE; |
DF, CF | image copies |
BACKUP DATABASE PLUS ARCHIVELOG; |
DF,CF,ARLF | backup set |
BACKUP AS COPY DATABASE PLUS ARCHIVELOG; |
DF,CF,ARLF | image copies |
BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT; |
DF,CF,ARLF, remove ARLF | backup set |
-- rman
-- View the structure of the CDB in terms of PDBs, tablespaces, and data files (permanent and temporary).
REPORT schema;
-- Back up the whole database.
BACKUP DATABASE;
-- List the backup sets.
LIST BACKUP;



cd /u01/app/oracle/fast_recovery_area/ORCL
ls -ltR

Takw-away:
As long as the database is in ARCHIVELOG mode, the backup can take place while the database is opened. This is a hot backup (or online backup).
Online backups are inconsistent because with the database opened, there is no guarantee that the data files are synchronized with the control files.If the database is in NOARCHIVELOG mode, it requires the database is closed. This is a cold backup (or offline backup).
offline backups taken while the database is not opened are consistent because, at the time of the backup, the system change number (SCN) in data file headers matches the SCN in the control files.Question: How can hot backups (inconsistent backups) be used in complete database recovery?
complete recovery, restored online backups are recovered until the current SCN is matched, with the use of the archive log files and online redo log files.-- rman
BACKUP AS COPY DATABASE PLUS ARCHIVELOG DELETE INPUT;
-- order:
-- archived log copy
-- delete archived log copy
-- datafile copy
-- SPFILE backup set
-- archived log copy
-- delete archived log copy



DBE_RECOVERY_FILE_DEST_SIZE parameter valueALTER SYSTEM SET db_recovery file dest size = 30G SCOPE=both;
Partial Database BackupPartial CDB Backup
datafiles of the CDB root,datafiles of defined PDBs,control file and SPFILE (configured to be backed up automatically)Autobackup is also valid for partial backups.
rman TARGET /
-- backup all datafiles in the CDB$root, including system, sysaux, undo, users
BACKUP PLUGGABLE DATABASE "CDB$ROOT"; -- quotation is needed
-- backup all datafiles in
BACKUP PLUGGABLE DATABASE pdb1;
-- backup all datafiles in Both CDB$root and pdb1
BACKUP PLUGGABLE DATABASE "CDB$ROOT", pdb1;
-- backup both CDB$root and pdb1 and archive log
BACKUP PLUGGABLE DATABASE "CDB$ROOT", pdb1 PLUS ARCHIVELOG;
When in CDB, backing up the archivelog with PDB is allowed.
-- rman
rman target /
BACKUP PLUGGABLE DATABASE pdb1 PLUS ARCHIVELOG;

- How many backup sets are created?
- Four backup sets:
- one for the
PDB data files,- one for the
SPFILEandcontrol file,- one for the
archived log filesbefore the data file backup set,- and one for the
archived log filesafter the data file backup set.
rman TARGET username@pdb
-- backup all df within the current pdb only
BACKUP DATABASE;
-- Do the same
BACKUP PLUGGABLE DATABASE pdb1;
-- Connect with pdb
rman target SYS@pdbl
-- backup current pdb
BACKUP DATABASE;

Notice that the
SPFILEandcontrol fileare - not backed up.



rman TARGET /
-- Show the names of all data files (permanent and temporary) and tablespaces
REPORT SCHEMA;
-- Backup a tbsp in a pdb
BACKUP TABLESPACE pdb1:users;
-- Backup multiple tbsp in different pdbs
-- if one of the identifiers is not correct, all backup will fail.
BACKUP TABLESPACE pdb1:system, orclpdb:sysaux;
-- Without pdb name: backup the tbsp within the CDB$ROOT
BACKUP TABLESPACE SYSTEM, orclpdb:users, SYSAUX;
-- order:
-- tbsp of current pdb
-- cf, spf
-- tbsp of other pdb
rman target /
BACKUP TABLESPACE pdb1:users;

SPFILE and control file are autobackup
-- connect with pdb
rman TARGET "'backupadmin@pdb1 as sysdba'"
-- Report schema in current pdb
REPORT SCHEMA;
-- Backup a tbsp in current a pdb
BACKUP TABLESPACE pdb1:users;
-- the pdb name can be ignore
BACKUP TABLESPACE system,users;
rman target SYS@pdb1
BACKUP TABLESPACE users;

SPFILE and Control file is not autobackup.