24.12.2012 Views

Backing Up Oracle - Computing at Cornell

Backing Up Oracle - Computing at Cornell

Backing Up Oracle - Computing at Cornell

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

11.4 Autom<strong>at</strong>ic deletion of old backups<br />

Autom<strong>at</strong>ing deletion of TDP for <strong>Oracle</strong> for Windows should be planned and<br />

tested carefully before implement<strong>at</strong>ion in a production environment. There is<br />

no simple command th<strong>at</strong> can be run to easily deactiv<strong>at</strong>e backups based on<br />

redundancy or time. One way to get around this is to use command files for<br />

autom<strong>at</strong>ion. Another way is to use tags as part of your backup process and<br />

use the same tags for deletion.<br />

11.4.1 Command files to autom<strong>at</strong>e backup deletion<br />

For this example to work, you must cre<strong>at</strong>e a directory c:\oracle\admin\scripts.<br />

In this directory you need to cre<strong>at</strong>e two files: autodelete.cmd and delete.sql,<br />

using a text editor. If you modify this directory p<strong>at</strong>h, you must modify the<br />

contents of both files. We needed to modify every occurrence of BEACH to<br />

m<strong>at</strong>ch our d<strong>at</strong>abase SID. You will need to modify manager in the occurrences<br />

of internal/manager to be the correct password for your d<strong>at</strong>abase. And you<br />

must modify rman/rman@rio to m<strong>at</strong>ch the username, password, and d<strong>at</strong>abase<br />

of your recovery c<strong>at</strong>alog.<br />

The command file autodelete.cmd does three things, sets ORACLE_SID,<br />

calls sqlplus to execute the delete.sql file, and calls RMAN using the<br />

delete_backup.rman file cre<strong>at</strong>ed by sqlplus.<br />

set ORACLE_SID=BEACH<br />

sqlplus internal/manager@beach @c:\oracle\admin\scripts\delete<br />

rman target internal/manager@beach rcvc<strong>at</strong> rman/rman@rio cmdfile=<br />

c:\oracle\admin\scripts\delete_backup.rman<br />

Figure 56. c:\oracle\admin\scripts\autodelete.cmd<br />

The delete.sql cre<strong>at</strong>es a file c:\oracle\admin\scripts\delete_backup.rman<br />

which logs on to the <strong>Oracle</strong> d<strong>at</strong>abase and queries the v$backup_piece for all<br />

backup pieces th<strong>at</strong> are not deleted(deleted=’NO’) and were backed up 3 days<br />

ago (completion_time < SYSDATE - 3). You can modify the where st<strong>at</strong>ement<br />

to m<strong>at</strong>ch any backup pieces th<strong>at</strong> you want.<br />

Chapter 11. Day-to-day monitoring on Windows 2000 185

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!