Monday 23 August 2010

RMAN CHANGE UNCATALOG



Catalog Backup
Whenever we take any backup through RMAN, in the repository information of the backup is recorded. The RMAN respository can be either controlfile or recovery catalog. However if I take a backup through OS command then RMAN does not aware of that and hence recorded are not reflected in the repository. This is also true whenever we create a new controlfile or a backup taken by RMAN is transferred to another place using OS command then controlfile/recovery catalog does not know about the prior backups of the database. So in order to restore database with a new created controlfile we need to inform RMAN about the backups taken before so that it can pick one to restore.

This task can be done by catalog command in RMAN. With catalog command it can
-Add information of backup pieces and image copies in the repository that are on disk.
-Record a datafile copy as a level 0 incremental backup in the RMAN repository.
-Record of a datafile copy that was taken by OS.

But CATALOG command has some restrictions. It can't do the following.
-Can't catalog a file that belong to different database.
-Can't catalog a backup piece that exists on an sbt device.

Examples of Catalog command
1)Catalog an archive log: To catalog two archived logs named /oracle/oradata/arju/arc001_223.arc and /oracle/oradata/arju/arc001_224.arc the command is,
RMAN>CATALOG ARCHIVELOG '/oracle/oradata/arju/arc001_223.arc', '/oracle/oradata/arju/arc001_224.arc';

2)Catalog a file copy as an incremental backup: To catalog datafile copy '/oradata/backup/users01.dbf' as an incremental level 0 backup your command will be,
RMAN>CATALOG DATAFILECOPY '/oradata/backup/users01.dbf' LEVEL 0;
Note that this datafile copy was taken backup either using the RMAN BACKUP AS COPY command, or by using operating system utilities in conjunction with ALTER TABLESPACE BEGIN/END BACKUP.

3)Catalog multiple copies in a directory: To catalog all valid backups from directory /tmp/backups issue,
RMAN>CATALOG START WITH '/tmp/backups' NOPROMPT;

4)Catalog files in the flash recovery area: To catalog all files in the currently enabled flash recovery area without prompting the user for each one issue,
RMAN>CATALOG RECOVERY AREA NOPROMPT;

5)Catalog backup pieces: To catalog backup piece /oradata2/o4jccf4 issue,
RMAN>CATALOG BACKUPPIECE '/oradata2/o4jccf4';

Uncatalog Backup
In many cases you need to uncatalog command. Suppose you do not want a specific backup or copy to be eligible to be restored but also do not want to delete it.
To uncatalog all archived logs issue,
RMAN>CHANGE ARCHIVELOG ALL UNCATALOG;

To uncataog tablespace USERS issue,
RMAN>CHANGE BACKUP OF TABLESPACE USERS UNCATALOG;

To uncatalog a backuppiece name /oradata2/oft7qq issue,
RMAN>CHANGE BACKUPPIECE '/oradata2/oft7qq' UNCATALOG;


SQL >> select 'Change backuppiece TAG='''|| TAG || ''' Uncatalog ; ' from rc_backup_piece where db_id = '952695440' and device_type = 'SBT_TAPE'

order by start_time

Result

----------------------------------------------------------------------
RMAN> Change backuppiece TAG='TAG20091021T200329' Uncatalog ;

RMAN> Change backuppiece TAG='TAG20091021T200337' Uncatalog ;
RMAN> CHANGE BACKUPPIECE TAG=' TAG20091023T200131' UNCATALOG;

RMAN> CHANGE BACKUPSET COMPLETED BEFORE 'sysdate-30' DELETE;

RMAN> CHANGE CONTROLFILECOPY '/u01/app/oracle/rman/backup/control01.ctl' UNCATALOG;

RMAN> CHANGE DATAFILECOPY '/u01/app/oracle/rman/backup/users01.ctl' UNCATALOG;

RMAN> CHANGE CONTROLFILECOPY '/tmp/cf.cpy' UNCATALOG;

RMAN> CHANGE BACKUPSET 121,122,127,203,300 UNCATALOG;

RMAN> CHANGE BACKUPPIECE 'ilif2lo4_1_1' UNCATALOG;


I want to remove RMAN catalog entries older than 30 days. The backup pieces have long since been moved off the system.


http://www.orafaq.com/scripts/unix/purgecat.txt

Just change the line
echo "CHANGE BACKUPSET $key DELETE;" >>$CMDFILE

in that script to
echo "CHANGE BACKUPSET $key UNCATALOG;" >>$CMDFILE

and also this line
list backupset of database
from time 'SYSDATE-3000' until time 'SYSDATE-$DAYSTOKEEP'


orrrrrrrrrrrrrrrrrrrrrr

RMAN> list backupset completed between '17-JAN-2011' and 'sysdate' ; --- to check today's backup
RMAN> change backupset completed before 'sysdate-30' delete;

RMAN> crosscheck backup completed before 'sysdate-30';
RMAN> delete expired backup completed before 'sysdate-30';

RMAN> list backupset tag 'VLE_LIVE_DISK' completed between "sysdate-1" and "sysdate";
RMAN> list backupset completed between "sysdate-3" and "sysdate-2";
RMAN> backup backupset completed between "sysdate-3" and "sysdate-2" format '/mnt/OracleBackup/BSQUAT/RmanOnline/FRA_BSQUAT_20100820_%U.frabak';
backup format 'FRA_%d_%T_%U.frabak'

Check Controlfile backup

run {
allocate channel d1 type='sbt_tape';
set until time "to_date('09-25-2014 20:00:00','mm-dd-yyyy hh24:mi:ss')";
restore controlfile preview;

}


No comments: