Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

RMAN on Windows: Dynamic Spool File

61 views
Skip to first unread message

basis_co...@hotmail.com

unread,
Sep 13, 2010, 4:50:35 PM9/13/10
to
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;

gazzag

unread,
Sep 14, 2010, 11:58:02 AM9/14/10
to
On 13 Sep, 21:50, "if_inves...@yahoo.com"

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=script_%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=<script_name> msglog=%LOG_FILE%

HTH
-g

John Hurley

unread,
Sep 14, 2010, 7:20:52 PM9/14/10
to
On Sep 13, 4:50 pm, "if_inves...@yahoo.com"

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 new messages