Chapter 11. Day-to-day monitoring on Windows 2000 185
11.4 Automatic deletion of old backups
Automating deletion of TDP for Oracle for Windows should be planned and
tested carefully before implementation in a production environment. There is
no simple command that can be run to easily deactivate backups based on
redundancy or time. One way to get around this is to use command files for
automation. Another way is to use tags as part of your backup process and
use the same tags for deletion.
11.4.1 Command files to automate backup deletion
For this example to work, you must create a directory c:\oracle\admin\scripts.
In this directory you need to create two files: autodelete.cmd and delete.sql,
using a text editor. If you modify this directory path, you must modify the
contents of both files. We needed to modify every occurrence of BEACH to
match our database SID. You will need to modify
manager in the occurrences
internal/manager to be the correct password for your database. And you
rman/rman@rio to match the username, password, and database
of your recovery catalog.
The command file autodelete.cmd does three things, sets ORACLE_SID,
sqlplus to execute the delete.sql file, and calls RMAN using the
delete_backup.rman file created by
Figure 56. c:\oracle\admin\scripts\autodelete.cmd
The delete.sql creates a file c:\oracle\admin\scripts\delete_backup.rman
which logs on to the Oracle database and queries the v$backup_piece for all
backup pieces that are not deleted(deleted=’NO’) and were backed up 3 days
ago (completion_time < SYSDATE - 3). You can modify the
to match any backup pieces that you want.
sqlplus internal/manager@beach @c:\oracle\admin\scripts\delete
rman target internal/manager@beach rcvcat rman/rman@rio cmdfile=