RMAN tag, add custom tags to Oracle RMAN backupsets

In Oracle Database version 11g or later, you can put parameters in the command line of RMAN, in previous versions this is not posible.

In some cases I did this with bash scripts:

Source   
#!/bin/bash
# By default environment variables have been loaded for
# data base TEST
export ORACLE_HOME=/oracle/u02/app/oracle/product/10.2.0/db_1
export ORACLE_BASE=/oracle/u02/app/oracle
export ORACLE_SID=TEST
export PATH=.:$ORACLE_HOME/bin:$PATH
export TNS_ADMIN=$ORACLE_HOME/network/admin
export fecha_actual=`date +%y%m%d%H%M%S`
LOGFILE="/oracle/u03/backup/logs/copia_caliente/copia_caliente_fullTEST_`date '+%d%m%y-%H:%M'`.log"
rman nocatalog target=/ log=$LOGFILE << EOF
run {
allocate channel t1 type 'SBT_TAPE';
allocate channel t2 type 'SBT_TAPE';
allocate channel t3 type 'SBT_TAPE';
allocate channel t4 type 'SBT_TAPE';
send 'NB_ORA_POLICY=P_Oracle_Full_Semanal, NB_ORA_SERV=serverfpsbackup';
sql 'alter system archive log current';
BACKUP AS COMPRESSED BACKUPSET INCREMENTAL LEVEL=0 DATABASE tag='BCK_COMPLETO${fecha_actual}';
backup as compressed backupset archivelog all tag='BCK_ARCHIVE_LOG${fecha_actual}' delete all input;
backup as compressed backupset current controlfile tag='BCK_CTRL${fecha_actual}';
}
EOF

What it does is define the variable “fecha_actual” is added to the tag.

The tag is something that is not given much importance normally, but when you have backups with different retention times is really useful. Sometimes you need to change a retention time of a backupset and use the tag to refer to it makes things easier.

Source   
LIST BACKUP SUMMARY;

It shows all backup sets with their tag among other things and can get more information, such as the retention time with:

Source   
LIST BACKUP TAG='BCK_COMPLETO111020120032';

And change the retention:

Source   
CHANGE BACKUPSET TAG='BCK_COMPLETO111020120032' NOKEEP;

Leave a Reply