Aug 4, 2016

Manage obsolete Backups and archivelogs

Use the DELETE command to remove backups or archivelogs that you do not want to retain. DELETE removes the physical files from the backup media, deletes the record of the backup from the recovery catalog (if RMAN is connected to a recovery catalog), and updates the records of these backups in the control file to status DELETED.

-- To delete archivelogs from disk before 'x'days

delete noprompt backup of archivelog until time 'sysdate-x';
e.g.,

RMAN> delete noprompt archivelog All completed before 'SYSDATE-2';


-- Deleting archived redo logs from disk using sequence

DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 'n';
e.g.,

RMAN> DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 1500;


-- Delete backups and archived redo logs from disk based on whether they are backed up on tape:

e.g.,
RMAN> DELETE ARCHIVELOG ALL BACKED UP 3 TIMES TO sbt;


-- Delete all expired archivelogs

RMAN> crosscheck archivelog all;
RMAN> delete noprompt expired archivelog all;

-- Delete orphan backups and archivelogs

Steps to remove orfan backups in rman:

rman>
run{
allocate channel for delete type sbt; ( if tape is configured, otherwise mention 'disk;)
report obsolete orphan;
report obsolete;
crosscheck backup;
crosscheck copy;
crosscheck backup of controlfile;

delete noprompt expired backup;
delete noprompt expired archivelog all;
delete noprompt expired backup of controlfile;
delete force noprompt expired copy;
delete force noprompt obsolete orphan;
delete force noprompt obsolete;
release channel;
}

-- Deleting Expired RMAN Backups after CROSSCHECK

run
{
CROSSCHECK BACKUP;
DELETE EXPIRED BACKUP;
}

If you are facing error like below, then delete with force.

RMAN-06207: WARNING: 1 objects could not be deleted for DISK channel(s) due
RMAN-06208:          to mismatched status.  Use CROSSCHECK command to fix status
List of Mismatched objects
==========================
  Object Type   Filename/Handle
--------------- ---------------------------------------------------
Backup Piece    1ux110yu_1_1

Then use:

RMAN> DELETE FORCE NOPROMPT BACKUPSET TAG 'weekly_bkup';

-- Deleting backups using primary keys from LIST output:

DELETE BACKUPPIECE 110;

-- Deleting backups by filename on disk:

DELETE CONTROLFILECOPY '/tmp/control01.ctl';

-- Deleting archived redo logs from disk:

DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 300;

-- Deleting backups based on tags:

DELETE BACKUP TAG='before_upgrade';

-- Delete backups based on the objects backed up and the media or disk location where the backup is stored:

DELETE BACKUP OF TABLESPACE users DEVICE TYPE sbt; # delete only from tape
DELETE COPY OF CONTROLFILE LIKE '/tmp/%';  #

Delete all backups for this database recorded in the RMAN repository:

DELETE BACKUP;

Delete backups and archived redo logs from disk based on whether they are backed up on tape:

DELETE ARCHIVELOG ALL BACKED UP 3 TIMES TO sbt;


-- use the REDUNDANCY or RECOVERY WINDOW clauses with DELETE to delete backups obsolete under a specific retention policy instead of the configured default:

DELETE OBSOLETE REDUNDANCY = 3;
DELETE OBSOLETE RECOVERY WINDOW OF 7 DAYS;

-- Recovery area size information

select name
,        floor(space_limit / 1024 / 1024) "Size MB"
,        ceil(space_used  / 1024 / 1024) "Used MB"
from   v$recovery_file_dest
order by name;


No comments:

Post a Comment

Translate >>