Note_Tech

All technological notes.


Project maintained by simonangel-fong Hosted on GitHub Pages — Theme by mattgraham

DBA - Whole Database Backup and Partial Database Backup

Back


Whole Database Backup

whole_backup01


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

Lab: Creating a Whole Database Backup

-- 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;

lab_whole_backup

lab_whole_backup

lab_whole_backup

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

lab_whole_backup


Takw-away:


Lab: Back up the database and archive logs as image copies.

-- 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

lab_whole_backup

lab_whole_backup


lab_whole_backup

ALTER SYSTEM SET db_recovery file dest size = 30G SCOPE=both;

Partial Database Backup


Backup Pluggable Database

Connect with CDB

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.


Lab: Backup Pluggable Database in CDB root

-- rman
rman target /

BACKUP PLUGGABLE DATABASE pdb1 PLUS ARCHIVELOG;

lab_pdb_backup

  • How many backup sets are created?
    • Four backup sets:
      • one for the PDB data files,
      • one for the SPFILE and control file,
      • one for the archived log files before the data file backup set,
      • and one for the archived log files after the data file backup set.

Connect with PDB

rman TARGET username@pdb

-- backup all df within the current pdb only
BACKUP DATABASE;

-- Do the same
BACKUP PLUGGABLE DATABASE pdb1;

Lab: Backup Pluggable Database in PDB

-- Connect with pdb
rman target SYS@pdbl

-- backup current pdb
BACKUP DATABASE;

pdb_bk

Notice that the SPFILE and control file are - not backed up.

pdb_bk

pdb_bk

pdb_bk


Backup Tablespace

Connect with CDB

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

Lab: Back up the tablespace in CDB

rman target /

BACKUP TABLESPACE pdb1:users;

lab_tbsp_backup

SPFILE and control file are autobackup


Connect with PDB

-- 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;

Lab: Back up the tablespace in PDB

rman target SYS@pdb1

BACKUP TABLESPACE users;

lab_tbsp_backup

SPFILE and Control file is not autobackup.


TOP