RMAN on Windows: Dynamic Spool File

  • Follow


Hi,

We are running Oracle 10g on Windows 2003. We intend to run an RMAN
batch script as follows: "rman target=/ @backup_script.sql".

Backup_script.sql contains a "spool log" command; I want to
change that command to spool to a dynamic filename, with
a date and time script. How can this be done?

Backup_script.sql is as follows:

spool log to 'E:\RMAN\RMANbackup.log';
Run {
  CONFIGURE CHANNEL ...
  BACKUP DATABASE;
  ......
 }
exit;
spool off;
0
Reply if_investor (20) 9/13/2010 8:50:35 PM

On 13 Sep, 21:50, "if_inves...@yahoo.com"
<basis_consult...@hotmail.com> wrote:
> Hi,
>
> We are running Oracle 10g on Windows 2003. We intend to run an RMAN
> batch script as follows: "rman target=3D/ @backup_script.sql".
>
> Backup_script.sql contains a "spool log" command; I want to
> change that command to spool to a dynamic filename, with
> a date and time script. How can this be done?
>
> Backup_script.sql is as follows:
>
> spool log to 'E:\RMAN\RMANbackup.log';
> Run {
> =A0 CONFIGURE CHANNEL ...
> =A0 BACKUP DATABASE;
> =A0 ......
> =A0}
> exit;
> spool off;

To my knowledge, what you want to achieve is not possible from within
the script, but Windows does provide some shell functionality that you
could use.

For example:

C:\>echo %DATE%
14/09/2010

Obviously forward slashes in a log file name are about as much use as
ashtrays on a motorbike, but Windows provides the following
functionality to reformat the output:

echo %DATE:~<start_position> , <number_of_characters>%  (Note:
<start_position> starts counting from zero)

E.g.

To display just the year portion of the output:

C:\>echo %DATE:~6,4%
2010

To display the month:

 C:\>echo %DATE:~3,2%
07

And the day of the month:

C:\>echo %DATE:~0,2%
01

So, to generate a log file with the format <script_name>_ddmmyy.log,
set an environment variable as follows:

C:\>set LOG_FILE=3Dscript_%date:~0,2%%date:~3,2%%date:~8,2%.log

C:\>echo %LOG_FILE%
script_140910.log

Then start RMAN as follows:

C:\> rman target / cmdfile=3D<script_name> msglog=3D%LOG_FILE%

HTH
-g
0
Reply gareth2106 (864) 9/14/2010 3:58:02 PM


On Sep 13, 4:50=A0pm, "if_inves...@yahoo.com"
<basis_consult...@hotmail.com> wrote:
> Hi,
>
> We are running Oracle 10g on Windows 2003. We intend to run an RMAN
> batch script as follows: "rman target=3D/ @backup_script.sql".
>
> Backup_script.sql contains a "spool log" command; I want to
> change that command to spool to a dynamic filename, with
> a date and time script. How can this be done?
>
> Backup_script.sql is as follows:
>
> spool log to 'E:\RMAN\RMANbackup.log';
> Run {
> =A0 CONFIGURE CHANNEL ...
> =A0 BACKUP DATABASE;
> =A0 ......
> =A0}
> exit;
> spool off;

There are a ton of scripting alternatives available in a windows
environment.

Why don't you figure out which of the options you want to use and do
some learning about writing scripts in that specific environment?
0
Reply hurleyjohnb (203) 9/14/2010 11:20:52 PM

2 Replies
547 Views

(page loaded in 0.669 seconds)

Similiar Articles:










7/22/2012 2:44:28 PM


Reply: