Re: Windows, RMAN, Environmeent Variables - Help!
Date: Tue, 19 Apr 2016 22:49:03 +1000
Message-ID: <5716293F.7070307_at_tpg.com.au>
Hi Norman,
Congratulations on your new job :)
I guess the single quotes may impede variable expansion, as WinNT is POSIX compliant. You'd have to escape them (with the caret ^ ).
Long time ago I wrote a generic backup script for use on Win2008, that I tested on windows 7. I'm not quite sure anymore exactly why, but it uses temporary files to feed the backup script into RMAN as in:
_at_(
echo run ^{ echo ALLOCATE CHANNEL d1 DEVICE TYPE DISK; echo set limit channel d1 kbytes ^= 4000000; echo backup echo FORMAT ^'%BACKUPDIR%\%%i\df_full_T%%t_S%%s_P%%p^' echo database include current controlfile plus archivelog; echo backup echo format ^'%BACKUPDIR%\%%i\sp_T%%t_S%%s_P%%p^' echo spfile; echo sql ^"create pfile=^'^'%BACKUPDIR%\%%i\init%%i.ora^'^' from spfile^"; echo sql ^"alter database backup controlfile to trace^"; echo crosscheck backup; echo crosscheck archivelog all; echo delete force noprompt obsolete; echo release channel d1; echo ^} echo exit
) > %TMPFLE%
rman target / _at_%TMPFLE% log %LOGFLE%
The double %% for the format variables is needed to preserve one % in the script.
If you're interested in the entire script, drop me a line privately.
Cheers,
Tony
On 19/04/16 19:08, Norman Dunbar wrote:
> Morning All,
>
> I'm on a new contract and i have to use Windows in the cloud! I'm a Unix guy normally, but needs must. ;-)
>
> I'm attempting to create a generic cmd script (I can't do Powershell, nor is it always guaranteed to be available on the servers I'm using) to run a level 0 or 1 incremental RMAN backup of the many 11.2.0.4 <http://11.2.0.4> databases in my care.
>
> Everything is Oracle 11.2.0.4 <http://11.2.0.4> by the way.
>
> I have a number of channels allocated with:
>
> allocate channel xxx
> device type disk
> format '%BACKUP_LOCATION%\%ORACLE_SID%\%U';
>
> When I run the script, I have defined at least the following:
>
> set ORACLE_SID=xxdba01
> set BACKUP_LOCATION=h:\backups
> set ORACLE_HOME=C:\ORACLEDATABASE\PRODUCT\11.2.0\DBHOME_1
>
> Depending on which server this is run on, BACKUP_LOCATION changes. On some it's H:\BACKUPS on others it's O:\BACKUPS.
>
> RMAN runs happily enough, allocates the channels, scans the list of data files but then barfs with the error:
>
> ORA-19504: failed to create file "C:\ORACLEDATABASE\PRODUCT\11.2.0\DBHOME_1\DATABASE\%BACKUP_LOCATION%\XXDBA01\1DR3DOF6_1_1"
>
> Where it appears to be creating the dump files in %ORACLE_HOME%\DATABASE\etc.
>
> I'm puzzled as to why %BACKUP_LOCATION% is not being expanded, but %ORACLE_SID% is, in the above file name. I suspect that the reason it's heading off to %ORACLE_HOME%\DATABASE is down the the non expansion of %BACKUP_LOCATION%, but why?
>
> Are there any Windows gurus out there who can give me a prod in the right direction please? If I can't get this to work in a generic format, I'm going to have to build a separate level 1 and level 0 script for each individual database.
>
> I am as ever, much obliged for any information. Thanks.
>
>
> Cheers,
> Norm.
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.
-- http://www.freelists.org/webpage/oracle-lReceived on Tue Apr 19 2016 - 14:49:03 CEST