Databases Reference
In-Depth Information
Table 9-3. ( continued )
Lines
Description
We again use realdate to extract the current time. For instance, if the program is executed at
11:15:53 p.m., the command realdate /t /s="set curtime=" yields set curtime=231553 . This
line places that string in the file tmp_tm.bat.
22
We execute the batch files we generated in the previous two lines. These set the variables curdate
and curtime .
23-24
27
We set the name of the log file.
28
We create a temporary log file to hold the output of the RMAN commands.
We create a variable called FORMATSTRING for the name of the backup piece.
31
We create a variable called CMDFILE to hold the name of the command file that will be passed to RMAN.
32
33-40
We put all the RMAN commands to be executed later in the command file.
44
We call the RMAN to execute the command file created dynamically in lines 33-40. The output goes
to the log file named in line 28.
47
Now that we have the output of the RMAN output, we place the contents of that RMAN log file to
the main log file we have been using.
We place the result of the RMAN run, as captured in the variable ERRORLEVEL . If the RMAN run was
successful, this variable will be 0. The result will be in the log file.
50
If there is any error, the log file will contain that error. This line shows how to use the findstr
command to find out whether the log file contains the word error in either uppercase or lowercase.
51
If the error was found, the errorlevel variable will be nonzero, and we want to e-mail the log file to
the address specified in the variable DBAPAGER . To send the e-mail, we have used a program called
bmail , which is described next.
52
After running the batch file, a log file is produced whose name is in the format <DbName>_<BackupType>_<What's
BeingBackedUp>_BKUP_<Target>_<Date>_<Time>.log . The log file shows the RMAN command file as well, which
confirms the actual command that was run.
Scheduling a Script in Windows via the GUI
Problem
You want to schedule a batch file or script in Windows to create a backup using the graphical user interface (GUI).
Solution
The Windows operating system has a task-scheduling interface that can be used to schedule tasks such as an RMAN
backup. Here are the steps to follow:
1.
Click Start Control Panel Scheduled Tasks Add a Scheduled Task. This opens the
wizard shown in Figure 9-1 .
 
 
Search WWH ::




Custom Search