Oracle RMAN 11g Backup and Recovery (183 page)

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


string_pattern


tempfileSpec

This subclause is used to define tempfiles by name or file number that should be operated on by the parent command.

Syntax Diagram


filename


integer

Appendix A: RMAN Syntax Reference Guide
619

toDestSpec

This subclause is used to specify a directory or an Automatic Storage Management disk group for disk backups for the RMAN operation that the subclause is used in.

Syntax Diagram


toDest_string


untilClause

This subclause defines a limit based on time, SCN, restore point, or log sequence number that is referenced by the parent RMAN command.

Syntax Diagram

UNTIL SCN

integer

THREAD

integer

UNTIL SEQUENCE

integer

UNTIL TIME


date_string


This page intentionally left blank

APPENDIX

B

RMAN Scripting

Examples

622
Part V: Appendixes

e have gotten a number of requests for scripts related to RMAN. The nice thing about RMAN is that scripting it is a pretty straightforward process. In this chapter, we provide you with some basic scripts for both Windows and Linux to get you started.

These scripts assume that you are using the Oracle flash recovery area (FRA), which will manage disk space and backup retention for you. If you are not using the FRA, perhaps you might want to customize these scripts for your own needs. We will leave that to your ingenuity and skill!

RMAN Scripts for Windows

These scripts were written and tested using Windows XP. First, we give you an example batch script that will call RMAN for a backup of the database and the archived redo logs. We will then show you a method of scheduling these scripts from the operating system. Note that this is just one method of scheduling automated backups. You might also choose to use Oracle Enterprise Manager (OEM) to schedule and manage your backups. Using Oracle Enterprise Manager is covered in Chapter 13, so you can reference that chapter for information on scheduling backups in OEM.

Creating a Windows Script to Schedule Backups

This is a pretty basic script; you might want to augment it for incremental backups, backup validation, or other operations. Note that the script will return an error message if the backup fails. To create this script, you might use Notepad, or some other text editor, and might call this script something like backup.bat.

rem ********************************************************************

rem * Script Name: backup.bat

rem * Script Purpose: This script will call RMAN and execute the command rem * file specified on the command line.

rem * Usage backup.bat

@echo off

rem

rem RMAN BACKUP SCRIPT

rem For WIN XP

rem

echo %1

set oracle sid %1

if "%2"

"backup" rman target / cmdfile c:\oracle\scripts\backup.scr

if not ERRORLEVEL 0 echo "WARNING - FAILURE OCCURRED"

if "%2"

"arch" rman target / cmdfile c:\oracle\scripts\arch.scr

if not ERRORLEVEL 0 echo "WARNING - FAILURE OCCURRED"

Note that this script calls two command files, backup.scr and arch.scr, which in this case are located in the c:\oracle\scripts directory.

Here is the backup.scr script:

Backup as compressed backupset database plus archivelog delete input;

This is the arch.scr script:

Backup as compressed backupset archivelog all delete input;

Appendix B: RMAN Scripting Examples
623

Again, each of these scripts would be created using a text editor and placed in the c:\oracle\

scripts directory. If you put them somewhere else, you will need to edit the backup.bat script to point to the correct location of these scripts.

Scheduling the Backup

Now, we want to schedule the backup. We will use the Windows schtasks utility to perform this operation. In our experience, schtasks is a rarely used but powerful scheduling utility. In this example, we are scheduling a daily database backup using the backup.bat file. We also have an example of scheduling the archived redo log backup and an example of how to remove a scheduled task:

schtasks /create /tn "database backup" /sc weekly /d SUN /st 14:50:00 /tr

"c:\bc\rman\backup.bat rob10r2 backup>\>c:\bc\rman\backup.output"

rem schtasks /delete /tn "database backup"

schtasks /create /tn "archivelog backup" /sc daily /st 14:50:00 /tr

"c:\bc\rman\backup.bat rob10r2 arch>\>c:\bc\rman\backup.output"

You have a number of scheduling options when using the schtasks scheduler. The schtasks scheduler will request the login ID of the user that will be running the job.

RMAN Scripts for Unix

These scripts were written and tested on Red Hat Linux Version 5. In this section, we have a backup script (backup.ksh) and the related command-line files that will be used to execute the actual backup. You can use Cron or at to schedule this script in Unix. First, here is our example shell script for our Unix backup:

Other books

Promises by Lisa L. Wiedmeier
Pie A La Murder by Wells, Melinda
Ponzi's Scheme by Mitchell Zuckoff
The Art Dealer by West, Megan
Final Grave by Nadja Bernitt
Strange Things Done by Elle Wild
The Alias Men by F. T. Bradley
The Skin Map by Stephen R. Lawhead