Contents:- Create Backup in Different
Ways i.e Backup Set, Image Copy, Archival Backup, Multisection Backup into
multipiece backup set, Incremental backup, leve 0 Backup, Level 1 Cumulative
Backup, Level 1 Differential Backup
Backup Types
Full Backup
Contains
all data file blocks.
Level 0 Incremental
Backup
Contains
all data file blocks same as full backup but the base for incremental backup.
Level 1 Cumulative Incremental
Backup
Contains
only blocks modified since the last level 0 incremental backup.
Level 1 Differential Incremental Backup
Contains
only blocks Modified since the last incremental backup(either level 0 or 1).
Creating Backup Sets
Backup
set is a collection of one or more files of backup.
RMAN> Backup as backupset format
‘/backup/df_%d_%s_%p.bus’ tablespace scm_data;
Creating Image Copies Backup
Image
copy backup means same to same (block to block) backup of a file same as by
operating system copy and paste command.
An image
copy is a clone of single Datafile, archivelog , redo log or control file.
An image
copy can be written only to disk. In Image copy backup time is increased
because all blocks are copies whether they contain data or not, but restoration
time is reduced. Here oracle database process copies the file and perform
additional actions such as Checking
for Corrupt blocks and registering the copy in the control file.
RMAN> Configure device type disk
backup type to copy;
or
RMAN> Backup as copy Datafile
‘/u01/app/backup/users_01_db01.dbf’;
RMAN> Backup as copy archivelog like
‘/u01/app/backup/arch%’;
To
Speedup the process of copying , you can use the NOCHECKSUM Parameter. By default RMAN
Computes the checksum of each block backed up, and stores it with the backup.
When the backup is restored the checksum(Is mainly used to detect the error) is
verified.
An Image
copy can be a part of a Full or Incremental Level 0 Backup because a file copy
always includes all blocks.
Creating a Whole Database Backup
RMAN> Backup database plus
archivelog DELETE INPUT.
9Or
RMAN> run
{
Backup database format device type disk
to ‘/u01/app/backup/db_%u_%d_%s’;
Sql ‘alter system archive log current’;
Backup format
‘/u01/app/oracle/backup/archivelog/log_t%t_s%s_%p%p’
(archivelog all delete all input);
}
Fast Recovery Area
Fast
Recovery Area would perform space management for you, deleting files when space
pressure grows.
Create a Backup (Backup set or image
copies) of previous image copies of all files.
RMAN> Backup copy of database;
Incremental Backup
Incremental
backup is either level 0 or level 1(cumulative or differential(default)).
RMAN> Alter database enable block
change tracking using file
‘/u01/app/oracle/incremental_backup/record.cts’;
We can
rename this block change tracking file but only when the database is in mount
stage.
RMAN> backup incremental level 0
database;
RMAN> backup incremental level 1
database;
RMAN> backup incremental level 1
cumulative database;
Monitor Block Change
Tracking
SQL> select filename,status,bytes
from V$block_Change_Tracking;
SQL> select
file#,avg(Datafile_blocks),avg(blocks_read),avg(blocks_read/Datafile_blocks)*100
PCT_READ_FOR_BACKUP, avg(blocks) from V$backup_datafile where
used_change_tracking=’YES’ and incremental_level>0 group by file#;
V$backup_datafile
view shows how effective the block change tracking is in minimizing the
incremental backup I/O (PCT_READ_FOR_BACKUP column). A high value indicates
that RMAN reads most blocks in the data file during the incremental backup. You
can reduce this ratio by decreasing the time between the incremental backups.
Full Image
copy can be incrementally updated
A Full
image copy can be incrementally updated by applying incremental backups with
the RECOVER Command.
Creating
Duplex Backup Set
RMAN>
backup as backupset device type sbt copies 2 incremental level 0 database;
Creating
Backups of Backup Sets
RMAN>
backup device type disk as backupset database plus archivelog;
RMAN>
backup device type sbt backupset all;
Skip Read only
table space during Backup.
You can
specify SKIP READONLY Option of the backup command to let RMAN know do not
backup read-only tablespace.
Creating RMAN
Multisection Backup.
During
the multisection backup a large Datafile is divided into number of section. And
each section backup separately into multipiece backupset.
Oracle
Datafile can be upto 128 TB in size.
RMAN
break up these large files into multiple section and backup and restore these
section independently by creating multisection backup.
Multisection
backup can only be done with backup sets not with image copies.
Backing
up a file into separate sections can improve the performance of the backup
operation, and it also allows large files backups to be restarted.
A
Multisection backup job produce a multipiece backup sets. Each piece contains
one section of the file. All sections of a multisection backup, except for the
last section, are of the same size. There are maximum 256 sections per file.
Compatible
must be set to at least 11.0
Syntax:
BACKUP
<options> SECTION SIZE <integer> [K | M | G]
VALIDATE
DATAFILE <options> SECTION SIZE <integer> [ K | M | G ]
Practical
RMAN>
backup Datafile 3 section size=25m TAG ‘section25mb’;
Viewing
Metadata about multi section backup
V$BACKUP_SET,
RC_BACKUP_SET
-
Views have a MULTI_SECTION Column. Which indicates whether this
is a multisection backup or not.
V$BACKUP_DATAFILE
and RC_BACKUP_DATAFILE
Views
have a SECTION_SIZE Column. Which specifies the number of
blocks in each section of a multisection backup. Zero means a whole file
backup.
Archival
Backup
If you
need to preserve an online backup for a specified amount of time. RMAN
Automatically assumes that you might want to perform point-In time recovery for
any issue since that backup to the present. To Satisfy this RMAN keeps archive
log for that time period.
Concepts
Requirements:
Simply
keep the specific backup. i.e for two years. You do not have intention of
recovering to a point in time since that backup, but you just want to be able
to recover to the exact time of the backup and no later. And parallel you also
want to maintain a retention policy that keeps your backup area free of
clutter, so making it reach back two years is not acceptable.
Solution
An
Archival backup solve this problem. If you mark a backup as an archival backup,
that attributes overrides any configured retention policy for the purpose of
this backup. This archival backup either considered obsolete only after the
time you specified or never.
The KEEP
Clause creates an archival backup that is a snapshot of the database at a point
in time. The only redo logs that are kept are those required to restore this
backup to a consistent state.
Backup
created with the KEEP Option include the SPFILE, Control Files and Archived
Redo Log Files required to restore this backup and data files.
After the
Archival backup is created, it is retained for as long as specified. Even if
you have much smaller retention window and run DELETE OBSOLETE command, the
archival backup remains.
Archive
backup cannot be written to fast recovery area.
Use
The
Archival backup can be used to restore the database to another host for testing
purpose.
Creating
Archival Backups with RMAN
Syntax:
KEEP {FOREVER
| UNTIL TIME [=] ‘date_string ‘}
NOKEEP
[ RESTORE
POINT rname ]
Practical
Archiving the Database Backup
RMAN> connect
target / catalog rman_user/rman_user@catdb
Rman>
change backup tag ‘consistent_db_backup’ keep forever; (This is Changes a
consistent backup into an archival backup)
Changing the status of a database copy
Rman> change
copy of database controlfile NOKEEP; (It will
change control file status from keep to nokeep so now it not exempt from the
existing retention policy and eligible for obsolete status).
List all
Restore Points
RMAN > list
restore point all;
Or
RMAN> list
restore point ‘restore_point name’;
Backing up
Recovery Files.
Backup
only the files in the fast recovery area
RMAN>
backup recovery area;
Back up
all Recovery Files.
RMAN>
backup recovery files;
RMAN Backup
Related Commands
RMAN>
LIST Display information about backup sets,
copies and image copies recorded in the repository.
RMAN>
REPORT Produces
a detailed analysis of the repository
RMAN>
report need backup- list all
data files that requires a backup.
RMAN>
report obsolete; identifies
the files that are no longer needed to satisfy backup retention policy.
Report
obsolete command reports which files are obsolete under the currently
configured retention policy.
RMAN>
crosscheck Verifies the status of backup and
copies recorded in the RMAN Repository against media such as disk or tape.
RMAN>
delete expired Removes
files whose status is expired in rman repository.
RMAN>
delete obsolete Delete
backups that are no longer needed.
Dynamic
Performance Views Related to Backup.
Target Database
V$backup_set
V$backup_piece V$datafile_copy
V$backup_files
Recovery Catalog Database
Rc_backup_set
rc_backup_piece rc_datafile_copy
rc_backup_files
In order
to query the RC_BACKUP_FILES view, first execute following command in recovery
catalog database.
Sql>
call dbms_rcvman.setdatabase(null,null,null,<dbid>);