Quantcast
Channel: A! Help
Viewing all articles
Browse latest Browse all 314

Parameterizing Backup Tags

$
0
0
At times it may be necessary to customize the back tag value. This could be achieved in two ways.
First method is used when a backups are run using a separate rman backup script file, which is used by the session invoking the rman. In this case the customized backup tags could be passed with the "USING" clause. Below is a simple rman backup script which takes a full database backup and archive log
cat backup.rmn
run {
backup database tag='&1' plus archivelog tag='&2';
delete noprompt obsolete;
}
Tags has been parameterized with the use of '&n'. Values for these are passed via the shell script that invokes rman
cat backup.sh
export ORACLE_SID=racse11g2
...
today_date=$(date +%F)
arctag=arch_bkp_$(date +%Y_%m_%d)
bkptag=full_bkp_$(date +%Y_%m_%d)
logfile=$ORACLE_SID"_"$today_date".log"
rman target / @/home/oracle/cronjobs/backup.rmn log /home/oracle/cronjobs/logs/$logfile using $bkptag $arctag
Result of this is customized tags for each days backup.
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
79 B A A DISK 06-OCT-15 1 1 NO ARCH_BKP_2015_10_06
80 B F A DISK 06-OCT-15 1 1 NO FULL_BKP_2015_10_06
81 B A A DISK 06-OCT-15 1 1 NO ARCH_BKP_2015_10_06
...
179 B A A DISK 07-OCT-15 1 1 NO ARCH_BKP_2015_10_07
180 B F A DISK 07-OCT-15 1 1 NO FULL_BKP_2015_10_07
181 B A A DISK 07-OCT-15 1 1 NO ARCH_BKP_2015_10_07



Second method is used when rman is invoked within a shell script. In this case customized tag is appended to a string
cat backupdisk.sh
export ORACLE_SID=racse11g1
...
logfile="disk_"$ORACLE_SID"_"$today_date".log"
tag=$(date +%Y_%m_%d)

rman target / log /home/oracle/cronjobs/logs/$logfile <<EOF
run
{
backup database tag = 'full_disk_$tag' format '/backup/full_bkp_%d_%T_%U' plus archivelog tag = 'full_arc_disk_$tag' format '/backup/full_arc_%d_%T_%U';
delete noprompt obsolete;
}
exit;
EOF
This will create customized tags as follows
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
83 B A A DISK 06-OCT-15 1 1 NO FULL_ARC_DISK_2015_10_06
84 B F A DISK 06-OCT-15 1 1 NO FULL_DISK_2015_10_06
85 B A A DISK 06-OCT-15 1 1 NO FULL_ARC_DISK_2015_10_06
...
183 B A A DISK 07-OCT-15 1 1 NO FULL_ARC_DISK_2015_10_07
184 B F A DISK 07-OCT-15 1 1 NO FULL_DISK_2015_10_07
185 B A A DISK 07-OCT-15 1 1 NO FULL_ARC_DISK_2015_10_07

Viewing all articles
Browse latest Browse all 314

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>