Oracle RMAN 11g Backup and Recovery (140 page)

BOOK: Oracle RMAN 11g Backup and Recovery
10.59Mb size Format: txt, pdf, ePub

Chapter 16: Maintaining RMAN
417

RMAN Workshop:
Using the delete Command

Workshop Notes

This workshop builds on the previous RMAN Workshop, “Using the
change
Command,” which deals with using the
crosscheck
command.

Step 1.
Having determined that the backup set piece is missing, we want to mark it as permanently missing. From the RMAN prompt, issue the
delete expired backup
command: RMAN> delete expired backup;

using channel ORA DISK 1

using channel ORA DISK 2

List of Backup Pieces

BP Key BS Key Pc# Cp# Status Device Type Piece Name

------- ------- --- --- ----------- ----------- ----------

53 53 1 1 EXPIRED DISK

D:\BACKUP\RECOVER\BACKUP 1VE25VC0 1 1

Do you really want to delete the above objects (enter YES or NO)?

Step 2.
Review the objects listed to be marked with a DELETED status. If they can all be marked as DELETED, reply to the prompt with a YES and press ENTER. Review the output for a successful operation:

deleted backup piece

backup piece handle D:\BACKUP\RECOVER\BACKUP 1VE25VC0 1 1 recid 53

stamp 472055171

Deleted 1 EXPIRED objects

Cataloging Other Backups in RMAN

The
catalog
command enables you to record datafile backups, archive log backups, and control file backups in RMAN, and these backups can later be used to restore and recover the database.

Oracle Database allows you to also use the
catalog
command to catalog existing backup set pieces in the control file. This is a nice feature if you have to restore the database with an old backup control file that might not have the most current RMAN information in it.

Here are some examples of the use of the
catalog
command to catalog old datafile backups:

-- first, backup the users tablespace

sqlplus sys/robert as sysdba

alter tablespace users begin backup;

host copy d:\oracle\oradata\recover\users01.dbf

d:\backup\recover\users01.dbf.backup

alter tablespace users end backup;

alter system archive log current;

host copy d:\oracle\admin\recover\arch\*.* d:\backup\recover

-- get a list of archivelog files that were created

host dir d:\backup\recover

alter database backup control file to 'd:\backup\recover.ctl'

quit

418
Part III: Using RMAN Effectively

-- Now, catalog the backup in rman

rman target sys/robert

catalog datafilecopy 'd:\backup\recover\users01.dbf.backup';

-- Replace arc001.log with the list of archive logs you generated earlier catalog archivelog 'd:\backup\recover\arc001.log';

-- Now catalog the control file.

catalog controlfilecopy 'd:\backup\recover.ctl';

The
catalog
command allows you to enter new backup set–related information into the control file or recovery catalog. RMAN overwrites any pre-existing catalog information that conflicts with the information being cataloged. This command can be handy if you need to move the location of your backup set pieces. In this example, we have moved all our backup set pieces to a new directory. We use the
catalog
command to load the correct directory location for each of the moved pieces in the control file:

RMAN> catalog backuppiece '/opt/oracle/oracle-10.0.0/dbs/backup';

You can also use the
catalog
command with the
start with
option, which allows you to define the directory that contains the RMAN backup set pieces to be cataloged. RMAN will then catalog all backup set pieces in that directory. Here is an example of using the
catalog
command in this way: RMAN> catalog start with '/u01/oracle/RMAN/mydb';

Once you press ENTER, this command prompts you with a list of files to catalog and asks if you wish to catalog the files listed. If you respond in the affirmative, RMAN catalogs all the backup set pieces listed (which will be contained in the /u01/oracle/RMAN/mydb directory). This command also allows you to catalog several like-named backup set pieces. For example, if you want to catalog several backup set pieces that start with the name “backup” (e.g., backupset01, backupset02, and so forth), then you could issue the following command:

RMAN> catalog start with '/u01/oracle/RMAN/mydb/backup';

When you use the
catalog start with
command, it is indiscriminate about which files it tries to catalog; it will try to catalog everything that matches the argument list. However, as the
catalog
process proceeds, files that are not backup set pieces will fail the catalog process and an error will occur. Files that are backup set pieces will be cataloged successfully, in spite of other errors.

RMAN Stored Scripts

If you find that you are often doing the same RMAN operations over and over, then you would probably like to be able to store those operations somewhere and execute them when needed.

Of course, you could create a command file, which is just a text file physically located on disk somewhere, with the RMAN commands, and then execute the command file from the RMAN

command-line interface using the
cmdfile
parameter, as shown in this example: rman target robert/password cmdfile run backup.cmd

Or, you can run a command file from within RMAN itself, using the
@
command:

@@run backup.cmd

Other books

Ashes of Another Life by Lindsey Goddard
Really Unusual Bad Boys by Davidson, MaryJanice
From the Dust Returned by Ray Bradbury
The Liar by Nora Roberts
The Mzungu Boy by Meja Mwangi
Mating Games by Glenn, Stormy, Flynn, Joyee
Ninja by John Man
No Home for the Holidays by Lillian Duncan
Tyler's Undoing by L.P. Dover
Son of the Shadows by Juliet Marillier