Wednesday, October 19, 2022

Oracle Database 11g -- Remove All SBT Backups Records from the Controlfile

Problem

You want to remove all the records about SBT backups from the controlfile

Solution

To remove all records from the controlfile the RMAN CHANGE ... UNCATALOG command must be used to uncatalog each backup piece separately

The below helper script automates the process. The process intentionally uses a set of intermediary files for verification or step by step execution with manual control over the process

Note. The script is supported by AIX platforms as well

rman target / <<EOF
spool log to rman.output
change backup device type sbt unavailable;
spool log off;
exit;
EOF

cat rman.output | grep "backup piece handle" > rman.output2
sed  "s/backup piece handle=/'/g" rman.output2 > rman.output3
awk -v TC=$(wc -l rman.output3 | awk '{ print $1 }') 'NR==TC { print $1"'"'"'" } NR!=TC {print $1"'"'",'" }' rman.output3 > rman.output4
echo "change backuppiece" > rman.output5
cat rman.output4 >> rman.output5
echo "uncatalog;" >> rman.output5

rman target / cmdfile=rman.output5

rman target /
list backup summary;



No comments: