Repository navigation
52. Oracle Full and Incremental Backups
┌──────────────────────────────────────────────────────────────┐
│ Define RPO/RTO (Recover point and time │
│ Backup window and capacity) │
└──────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐
│ Choose baseline (Full or level zero │
│ Backup set or image copy) │
└──────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐
│ b Daily incremental (Differential or │
│ cumulative changed backup only) │
└──────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐
│ Archive Logs (Back up redo, │
│ protect recovery change) │
└──────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐
│ Write Backup (Disk / FRA / SBT │
│ Tag and record metadata) │
└──────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐
│ Monitor & List (V$RMAN views │
│ LIST BACKUP SUMMARY) │
└──────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐
│ Validate Restore (RESTORE VALIDATE │
│ Preview required backup/logs) │
└──────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐
│ Retain/Crosscheck(Retention policy and metadata health │
└──────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐
│ Recovery Ready (Backups and logs available) │
└──────────────────────────────────────────────────────────────┘
Strategy flow: define objective -> baseline -> incrementals -> archive logs -> monitor -> validate -> retain -> remain recovery ready
┌──────────────────────────────────────────────────────────────┐
│ Level 0 Full(Baseline datafile backup restored first) │
└──────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐
│ Level 1 Backups (Apply changed blocks │
│ Differential or cumulative) │
└──────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐
│ Archived Logs (Roll forward to target │
│ SCN/time complete recovery chain) │
└──────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐
│ Recovered Database (Open normally or │
│ RESETLOGS Depends on recovery type) │
└──────────────────────────────────────────────────────────────┘
┌────────────────────────────────────────────────────────────────────────────────────┐
│ RMAN Chooses the required Backup chain Automatically │
│ (RESTORE selects backup pieces RECOVER applies incremental and archived redo) │
│ Use RESTORE...PREVIEW and RESTORE...VALIDATE before an incident │
└────────────────────────────────────────────────────────────────────────────────────┘
-
RMAN restores the baseline full or level 0 backup.
-
RMAN applies the necessary level 1 backups to move datafiles towards efficiently.
-
Archived redo logs and online redo are applied to reach the required recovery point.
-
The database is opened normally after complete recovery or with RESETLOGS after incomplete recovery.
Backup of used blocks of selected files. Cannot serve as parent of level 1 unless it is level 0.
Incremental baseline containing all used blocks. Parent for level 1 backups.
Changed blocks since most recent level 0 or level 1. Smallest daily backup, longer recovery chain.
Changed blocks since most recent level 0. Larger daily backup, shorter recover chain.
RMAN proprietory logical backup. Can be compressed and skips unused blocks.
Physical Copy of a datafile, control file or archived log. Usedful for incrementally updated copy strategy.
A level assigned to the backup file. Used for listing and restore selection.
System change number, a number generated every nano second the database is active, used in many things, like to put the SCN of the commited DML sentence in control file and the header of data file to know which statements are commited. Used with redo to recover consistently.
Backup Type: Full
Blocks Included: All used blocks
Can be Level 1 parent: No unless explicitly level 0.
Typical Use: Standalone full backup.
Backup Type: Incremental Level 0
Blocks Included: All used blocks
Can be Level 1 parent: Yes
Typical Use: Weekly baseline.
Backup Type: Level 1 differential
Blocks Included: Blocks changed since latest level 0 or level 1.
Can be Level 1 parent: N/A
Typical Use: Small daily backup.
Backup Type: Full
Blocks Included: Blocks changed since latest level 0.
Can be Level 1 parent: N/A
Typical Use: Faster restore/recovery.
Note: A full backup and level 0 backup may contain similar data, but only level 0 is recognised as an incremental baseline.
Storage Format: RMAN propritory backup pieces.
Compression: Supports RMAN compression.
Unused Block Skipping: Supported. Unused blocks over High water mark can be skipped.
Restore: Must be restored.
Typical Use: Standard Backup Strategy.
Command: Backup database;
Storage Format: Exact copy of source file.
Compression: Not normally compressed by RMAN. Same size as source.
Unused Block Skipping: Not applicable in the same way. Whole file is copied.
Restore required: Can switch directly to copies.
Typical Use: Fast recovery/incremental updated copies.
Command: Backup as copy database.
Backup status, input type, duration, compression, throughput
Cuurrent and historical RMAN Operations.
Backup set metadata during incremental level.
Backup piece file details.
Datafile backup metadata and checkpoint SCNs.
Archive log backup records.
Known corrupt blocks.
Backup and restore progress.
Display RMAN repository backup inventory.
Checks whether backups can be read and selected.
Shows required backup and redo chain. (?)
select name, open_mode, log_mode, database_role, force_logging from v$database;
select instance_name, host_name, status, startup_time from v$instance;
select file#, name, status, enabled, checkpoint_change# from v$datafile order by file#;
select dest_id, status, destination, error from v$archive_dest_status where status <> 'INACTIVE' order by dest_id;
select name, space_limit/1024/1024/1024 as limit_gb, space_used/1024/1024/1024 as used_gb, space_reclaimable/1024/1024/1024 as reclaimable_gb from v$recovery_file_dest;
show all;
host df -h /u05/rman host df -i /u05/rman host ls -id /u05/rman
rman target /
show all
run
{
allocate channel c1 device type disk format '/u05/rman/full_%d_%T_%U.bkp';
backup as compressed backupset database tag='FULL_DB_LAB';
backup current controlfile tag='full_db_lab_controlfile';
backup spfile tag='full_db_lab_spfile';
release channel c1;
}
list backup tag='full_db_lab'; list backup of controlfile; list backup of spfile;
select session_key, input_type, status, start_time, end_time, input_bytes_display, output_bytes_display, compression_ratio from v$rman_backup_job_details order by start_time desc fetch first 10 rows only;
backup incremental level 0 as compressed backupset database tag='weekly_L0';
list backup tag='weekly_L0';
select bs.recid, bs.set_stamp, bs.set_count, bs.incremental_level, bs.backup_type, bs.start_time, bs.completion_time, bp.handle, bp.bytes/1024/1024 as piece_mb from v$backup_set bs inner join v$backup_piece bp on bp.set_stamp = bs.set_stamp and bp.set_count = bs.set_count where bs.incremental_level = 0 order by bs.completion_time desc;
Backup incremental level 1 as compressed backupset database tag 'daily_l1_diff';
RMAN backs up the blocks changed since the most recent level 0 or level 1 backup. Every day's backup is usually smaller but recovery may require multiple level 1 backups.
list backup tag 'daily_l1_diff';
backup incremental level 1 cumulative as compressed backupset database tag 'weekly_l1_cumu';
RMAN backs up the blocks changed since the most recent level 0 backup. This backup is larger than differential level 1 but recovery generally larger but recovery needs only the last level 0 backup and the most latest level 1 backup.
list backup tag 'daily_l1_cumu';
+-----------------+------------------------------------+-----------------------------------+ | Feature | Differential Backup | Cumulative Backup | +-----------------+----------------------------------- +-----------------------------------+ | Backup size | Usually smaller | Usually larger | | Backup time | Usually shorter | Usually longer | | Recovery chain | May require several level 1 backups| Requires latest cumulative level 1| | Recovery time | Potentially longer | Potentially shorter | +-----------------+------------------------------------+-----------------------------------+
backup as copy database tag 'db_image_copy';
list copy of database;
list backup summary;
list backup of database;
list backup of database completed after 'sysdate -7';
list backup of archivelog all;
List backup tag 'weekly_l0'; List backup tag 'weekly_l1_diff'; List backup tag 'weekly_l1_cumu';
Select handle, status, device_type, bytes/1024/1024 as size_mb, start_time, completion_time, compressed, tag from v$backup_piece order by completion_time desc fetch first 50 rows only;
Select file#, incremental_level, checkpoint_change#, checkpoint_time, completion_time, blocks, datafile_blocks from v$backup_datafile order by completion_time desc, file#;
Select sid, serial#, opname, target, sofar, totalwork, units, round(sofar*100/nullif(totalwork,0),2 as pct_done, elapsed_seconds, time_remaining from v$session_longops where opname like 'RMAN%' and totalwork > 0 and sofar <> totalwork order by start_time;
Select session_key, input_type, status, start_time, end_time, elapsed_seconds, input_bytes_display, output_bytes_display, input_bytes_per_sec_display, output_bytes_per_sec_display, compression_ratio from v$rman_backup_job_details order by start_time desc fetch first 20 rows only;
Select session_recid, operation, status, start_time, end_time, object_type, output_bytes from v$rman_status where status like 'RUNNING%' order by start_time;
Restore database preview summary;
restore database validate;
Backup validate check logical database;
Restore controlfile validate: Restore spfile validate
Select file#, block#, blocks, corruption_change#, corruption_type from v$database_block_corruption order by file#, block#;
Report need backup recovery window of 7 days;
+-----------------+--------------------------+--------------------------------------------------------+ | DAY | BACKUP | PURPOSE | +-----------------+--------------------------+--------------------------------------------------------+ | Sunday | Incremental level 0 | Weekly baseline | +-----------------+--------------------------+--------------------------------------------------------+ | Monday | Level 1 differential | Changes since sunday level 0 | +-----------------+--------------------------+--------------------------------------------------------+ | Tuesday | Level 1 differential | Changes since monday level 1 | +-----------------+--------------------------+--------------------------------------------------------+ | Wednesday | Level 1 cumulative | Changes since sunday level 0; shorter recovery chain | +-----------------+--------------------------+--------------------------------------------------------+ | Thursday | Level 1 differential | Changes since wednesday | +-----------------+--------------------------+--------------------------------------------------------+ | Friday | Level 1 differential | Changes since thursday | +-----------------+--------------------------+--------------------------------------------------------+ | Saturday | Level 1 cumulative | Latest cumulative before next level 0 | +-----------------+--------------------------+--------------------------------------------------------+ | Every 4-6 hours | Archive logs | Reduce data loss exposure. | +-----------------+--------------------------+--------------------------------------------------------+
Sunday is level 0 (level 0 is the same for both differential and cumulative) which is full backup datawise.
Monday we can take level 1 differential backup,
Tuesday we can take another level 1 differtial backup (as if Mondays backup got deleted there will no no data loss as that level 1 backup will record all changes happened after Sunday's level 0.
Wednesday we will take a level 1 cumulative, as in Wednesday's case if Mondays data got deleted, but Tuesday's remain intact then, Monday's changes will not be backed up again as differential level 1 backup only record the changes takes place after most recent level 0 and level 1 backup. This will break the chain. So we take cumulative level 1 backup here which always backups all the changes happened after last level 0, i,e after sunday.
Thursday we take another level 1 differential as we already have the cumulative level 1 backup in Wednesday.
Friday we also take a differential level 1 backup again as there will no risk of breaking the chain is Thursday's backup got deleted.
Saturday we will take another level 1 cumulative backup for the same reason as Wednesday.
----Sunday Backup incremental level 0 database tag 'weekly_l0'; ----Monday, Tuesday, Thursday, Friday Backup incremental level 1 database tag 'weekly_l1_diff'; ----Wednesday, Saturday Backup incremental level 1 cumulative database tag 'weekly_l1_cumu'; -----Every 4-6 hours Backup archivelog all not backed up 1 times;
RMAN may create a level 0 equivalant baseline bahavior depending on circumstances, but the strategy should explicitly schedule a level 0.
list backup of database;
host df -h /u05/rman/ host df -i /u05/rman/
report obsolete; crosscheck backup; list expired backup;
crosscheck backup; list expired backup;
Restore mount or file access before deleting metadata if the backup is still required.
Possible causes:
-
High changed block workload
-
Block changed tracking dissabled or unavailable
-
Large batch operations
-
Level 0 too old
-
Nologging opeartions requiring additional protection.
select status, filename, bytes from v$block_change_tracking;
alter database enable block change tracking using file '/u01/app/oracle/oradata/PRODUCTION/control01.ctl';
alter database disable block change tracking;
list backup summary; crosscheck backup; restore database preview; restore database validate;
-
Confirm database, host, role, log_mode, FRA and destination.
-
Review show all and retention policy
-
Confirm control file autobackup and SPFILE protection.
-
Validate free space and mount availability.
-
Check recent backup failures and expired peices.
-
Confirm data gaurd archived log deletion requirements.
-
Use tags and timestamped logs.
show all; crosscheck backup; crosscheck archivelog all; list backup summary; report obsolete;
list backup summary; list backup of database; list backup of archivelog all; restore database preview summary; restore database validate;
Select input_type, status, start_time, end_time, elapsed_seconds, input_bytes_display, output_bytes_display, compression_ratio from v$rman_backup_job_details order by start_time desc fetch first 10 rows only;