Pavan DBA's Blog

The DBA Knowledge Store

Archive for the ‘Scripts’ Category

script to check free space in a datafile

Posted by Pavan DBA on March 30, 2012


Friends, Many a times we will be requiring to resize a datafile. For suppose, we have a tablespace with 3 datafiles with equal size. Then how we would be knowing which datafile to increase?? It is based on free space in a datafile. So, the below script will provide the info of how much free space is left in each datafile for a tablespace

#################################################

DATAFILE FREE SIZE

#################################################

 

SELECT SUBSTR (df.NAME, 1, 40) file_name,dfs.tablespace_name, df.bytes / 1024 / 1024 allocated_mb,

((df.bytes / 1024 / 1024) – NVL (SUM (dfs.bytes) / 1024 / 1024, 0))

used_mb,

NVL (SUM (dfs.bytes) / 1024 / 1024, 0) free_space_mb

FROM v$datafile df, dba_free_space dfs

WHERE df.file# = dfs.file_id(+)

GROUP BY dfs.file_id, df.NAME, df.file#, df.bytes,dfs.tablespace_name

ORDER BY file_name;

Posted in Administration, Scripts | Tagged: , | 3 Comments »

script to delete applied archives on standby database on windows OS

Posted by Pavan DBA on March 26, 2012


#############################################################

windows script for deleting applied archives in standby database

#############################################################

windows:

There is a configuration file “E:\dba\orahome\mntdir\config\dba.xml” (you should replace { and } with the ones used in standard xml. I can not use them in this post, corrupts page)

 

{?xml version=”1.0″ encoding=”utf-8″ ?}

{config}

{general}

{archive_format}ARC_0628272535_001_SEQUENCE.ARC{/archive_format}

{archive_dir}E:\oracle\oradata\archive{/archive_dir}

{/general}

{stby}

{prodUser}dbuser{/prodUser}

{prodPass}password{/prodPass}

{prodTNS}PROD{/prodTNS}

{/stby}

{/config}

 

There is a file “E:\dba\orahome\stby\archive_last_deleted.txt” in which last deleted archived log’s sequence number is kept. At first it can be set as 1.

My scheduled vbs script “E:\dba\orahome\stby\stby_archclean.vbs” uses configuration file to connect primary site, query dataguard status and delete applied archived logs at standby server:

 

‘********************* CODE TO PARSE DBA.XML FILE ****************************

Set oXMLDoc = CreateObject(“MSXML2.DOMDocument.3.0”)

oXMLDoc.async = False

If Not oXMLDoc.load(“mntdir\config\dba.xml”) Then

Set oErr = oXMLDoc.parseError

sErrMsg = “XML Parsing Error. File: ” & oErr.url & ” Reason : ” & oErr.reason & ” Line: ” & oErr.line & “, Character: ” & oErr.linepos & “,Text: ” & oErr.srcText

Err.Raise 999, , sErrMsg

End If

‘******************************************************************************

 

Set WshShell = CreateObject(“WScript.Shell”)

pUSER = oXMLDoc.selectSingleNode(“/config/stby/prodUser”).text

pPASS = oXMLDoc.selectSingleNode(“/config/stby/prodPass”).text

ARCHIVE_FORMAT = oXMLDoc.selectSingleNode(“/config/general/archive_format”).text

ARCHIVE_DIR = oXMLDoc.selectSingleNode(“/config/general/archive_dir”).text

pTNS = oXMLDoc.selectSingleNode(“/config/stby/prodTNS”).text

 

Set objFSO = CreateObject(“Scripting.FileSystemObject”)

set archive_last_deleted = objFSO.OpenTextFile(“stby\archive_last_deleted.txt”, 1) ‘for reading

DIM LAST_DELETED

if not archive_last_deleted.AtEndOfStream then

LAST_DELETED = cInt(archive_last_deleted.ReadLine)

else

WScript.Echo “Error on stby\archive_last_deleted file”

WScript.exit

end if

archive_last_deleted.close

NEXTTODELETE=LAST_DELETED+1

 

 

 

‘ADO Connection object

Set con = CreateObject(“ADODB.Connection”)

con.CursorLocation = 3

If con.State = 1 Then con.close

con.Open “PROVIDER=MSDAORA;DATA SOURCE=”&pTNS&”;USER ID=”&pUSER&”;PASSWORD=”&pPASS&”;”

 

‘ADO Command object

Set cmd = CreateObject(“ADODB.Command”)

cmd.CommandText=”select APPLIED_SEQ#-3 from v$ARCHIVE_DEST_STATUS where DEST_ID=2 ”

cmd.CommandType=1

cmd.ActiveConnection=con

 

‘ADO Recordset object

set rs=CreateObject(“ADODB.Recordset”)

Set rs=cmd.Execute

 

 

if rs.EOF then

WScript.Echo “Error: No APPLIED_SEQ# record for DEST_ID 2”

rs.Close

con.Close

WScript.exit

else

DIM MAX_SEC_APPLIED

rs.MoveFirst

MAX_SEC_APPLIED = cInt(rs.Fields(0))

rs.Close

con.Close

end if

 

WScript.Echo “Archive Sequence Range to Clean:” & cStr(NEXTTODELETE) & ” – ” & cStr(MAX_SEC_APPLIED)

do while MAX_SEC_APPLIED > NEXTTODELETE

WScript.Echo “removing… ” & ARCHIVE_DIR & “\” & Replace(ARCHIVE_FORMAT,”SEQUENCE”,cStr(NEXTTODELETE))

‘WshShell.run(“del /Q ” & ARCHIVE_DIR & “\” & Replace(ARCHIVE_FORMAT,”SEQUENCE”,cStr(NEXTTODELETE)))

objFSO.DeleteFile ARCHIVE_DIR & “\” & Replace(ARCHIVE_FORMAT,”SEQUENCE”,cStr(NEXTTODELETE))

set archive_last_deleted = objFSO.OpenTextFile(“stby\archive_last_deleted.txt”, 2) ‘for writing

archive_last_deleted.Write cStr(NEXTTODELETE)

archive_last_deleted.close

NEXTTODELETE = NEXTTODELETE+1

loop

 

Posted in Dataguard, Scripts | Tagged: | Leave a Comment »

script for deleting applied archive on standby database on unix OS

Posted by Pavan DBA on March 26, 2012


#############################################################

unix script for deleting applied archives in standby database

#############################################################

#!/usr/bin/ksh

ARCH_DIR=/archive/orcl

 

#take the log number to be applied

LogNo=`tail -30000 /oracle/app/oracle/product/10.2.0/admin/orcl/bdump/alert* | grep “Media Recovery Log” | cut -d ” ” -f 4 | cut -d “_” -f 5 | tail -1 `

echo “Oracle applied LogNo is $LogNo”

 

#extract 10

let SecLogNo=${LogNo}-10

echo “new backlog log No: $SecLogNo”

 

#delete small numbers from this in arch dir

cd $ARCH_DIR

for i in `ls *.arc`

do

 

Newi=`echo $i | cut -d “_” -f 4`

if [ $Newi -lt $SecLogNo ] ; then

echo “$i to be deleted…”

rm $i

fi

done

Posted in Dataguard, Scripts | Tagged: , | Leave a Comment »

script for archives backup in windows

Posted by Pavan DBA on March 26, 2012


#################################

PURGING ARCHIVE LOGS

################################

rem ——————————————————————————————–

rem ——————————————————————————————–

rem -*-

rem -*- Description: Purge old archive logs script for Oracle NT database main program

rem -*-

rem -*- Source file: %ora_utl_dir%\purge_arch_logs.bat

rem -*-

rem — This job:

rem — 1. Removes archived logs from %ora_arch_save_dir% directory

rem — 2. copies archived logs from %ora_arch_dir% directory to %ora_arch_save_dir% directory

rem — 3. Removes archived logs older than %older_than_days% days from %ora_arch_dir% directory

rem -*-

rem -*- Author : Diana Farazi

rem -*- Date Written: 04/20/2000

rem -*-

rem -*- Modification log:

rem -*- Mod Ver Date Who Desciption

rem -*- ——- ———- —————— ————————-

rem -*-

rem ——————————————————————————————–

rem ——————————————————————————————–

 

set ora_sid=PRD2

set ORACLE_SID=%ora_sid%

set tns=bp1tulap151_%ora_sid%

set ora_system_id=system/rsdbsite

set ora_log_dir=i:\d002\oracle\%ora_sid%\utillogs\trim

set ora_utl_dir=i:\d002\oracle\%ora_sid%\utilitys\trim

set ora_vbs_dir=i:\d002\oracle\vbs

 

set ora_arch_dir=i:\d802\oracle\%ORACLE_SID%\arch

set ora_arch_save_dir=i:\d802\oracle\%ORACLE_SID%\arch\save

 

set purge_arch_logs_log=%ora_log_dir%\purge_arch_logs.log

set save_purge_arch_logs_log=%ora_log_dir%\save_purge_arch_logs.log

set older_than_days=2

set email=dba_ora_offshore@bp.com

##set email2=dba_ora_onshore@bp.com

set email_message=

set line=—————————————————————————

set star=*

set error_count=0

 

 

echo %line% > %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

now purge_arch_logs START for %tns% database >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

echo This is: %0 script >> %purge_arch_logs_log%

 

echo %star% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

rem ———————————————————————————————

rem — . . . Before Purge

rem ———————————————————————————————

echo %line% >> %purge_arch_logs_log%

echo . . . Before Purge >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

 

rem ———————————————————————————————

rem — . . . Before Purge – Listing archive logs in %ora_arch_dir%

rem ———————————————————————————————

echo %line% >> %purge_arch_logs_log%

echo . . . Before Purge – Listing archive logs in %ora_arch_dir% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

dir %ora_arch_dir%\*.* >> %purge_arch_logs_log%

 

rem ———————————————————————————————

rem — . . . Before Purge – Listing archive logs in %ora_arch_save_dir%

rem ———————————————————————————————

echo %line% >> %purge_arch_logs_log%

echo . . . Before Purge – Listing archive logs in %ora_arch_save_dir% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

dir %ora_arch_save_dir%\*.* >> %purge_arch_logs_log%

 

rem ———————————————————————————————

rem — . . . Removing archive logs from %ora_arch_save_dir%

rem ———————————————————————————————

echo %line% >> %purge_arch_logs_log%

echo . . . Removing archive logs from %ora_arch_save_dir% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

del %ora_arch_save_dir%\arch*.log

 

rem ———————————————————————————————

rem — . . . Copying archive logs from %ora_arch_dir% to %ora_arch_save_dir%

rem ———————————————————————————————

echo %line% >> %purge_arch_logs_log%

echo . . . Copying archive logs from %ora_arch_dir% to %ora_arch_save_dir% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

copy %ora_arch_dir%\arch*.* %ora_arch_save_dir%\

 

rem ———————————————————————————————

rem — . . . Removing archive logs from %ora_arch_dir% older than %older_than_days%

rem ———————————————————————————————

echo %line% >> %purge_arch_logs_log%

echo . . . Removing archive logs from %ora_arch_dir% older than %older_than_days% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

cscript.exe %ora_vbs_dir%\cleanupoldfiles.vbs -d %ora_arch_dir% -o %older_than_days% >> %purge_arch_logs_log%

 

rem ———————————————————————————————

rem — . . . After Purge

rem ———————————————————————————————

echo %star% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo . . . After Purge >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

 

rem ———————————————————————————————

rem — . . . After Purge – Listing archive logs in %ora_arch_dir%

rem ———————————————————————————————

echo %line% >> %purge_arch_logs_log%

echo . . . After Purge – Listing archive logs in %ora_arch_dir% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

dir %ora_arch_dir%\*.* >> %purge_arch_logs_log%

 

rem ———————————————————————————————

rem — . . . After Purge – Listing archive logs in %ora_arch_save_dir%

rem ———————————————————————————————

echo %line% >> %purge_arch_logs_log%

echo . . . After Purge – Listing archive logs in %ora_arch_save_dir% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

dir %ora_arch_save_dir%\*.* >> %purge_arch_logs_log%

 

rem ———————————————————————————————

rem — . . . END Purge

rem ———————————————————————————————

echo %line% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

now purge_arch_logs END for %tns% database >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

echo %line% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

 

type %purge_arch_logs_log% >> %save_purge_arch_logs_log%

 

Posted in backup and recovery, Scripts | Tagged: , , , | Leave a Comment »

script for cold backup in windows

Posted by Pavan DBA on March 26, 2012


###########################

COLD BACKUP IN WINDOWS

#############################

rem ——————————————————————————————-

rem ——————————————————————————————-

rem -*-

rem -*- Description: Cold backup script for Oracle NT database main program

rem -*-

rem -*- Source file: %ora_utl_dir%\cb_cold_backup.bat

rem -*-

rem -*- Instructions:

rem -*- 1. Create the following directories:

rem -*- ora_back_dir

rem -*- ora_log_dir

rem -*- ora_utl_dir

rem -*- ora_vbs_dir

rem -*- ora_recv_dir

rem -*-

rem -*- 2. Change variables below as needed

rem -*-

rem -*- 3. In order to execute the cscript.exe %ora_vbs_dir%\sendmailattach.vbs

rem -*- you must have the SNMP service running, cscript.exe and ste50en.exe

rem -*-

rem -*- Author : Diana Farazi

rem -*- Date Written: 03/24/2000

rem -*-

rem -*- Modification log:

rem -*- Mod Ver Date Who Desciption

rem -*- ——- ———- ——– ——————————————————

rem -*- 1.1 09/08/2000 farazid added CALL %ora_vbs_dir%\upper_case.bat %search_for%

rem -*- set search_for=%RET%

rem -*- created upper_case.bat in the %ora_vbs_dir%

rem -*- 1.2 09/22/2003 farazid added Net Stop and Net Start SampleManager services

rem -*- sections (must be executed in this order!):

rem -*-

rem -*- Net STOP SampleManager services:

rem -*- (1)smpbackVGLP,(2) smwVGLP,(3)smpVGLP

rem -*-

rem -*- 2.0 01/29/2004 farazid Oracle9i modified and tested

rem ——————————————————————————————-

rem ——————————————————————————————-

 

set ora_sid=PRD2

set ORACLE_SID=%ora_sid%

set tns=bp1tulap151_%ora_sid%

set ora_sys_id=”sys/rsdbsite as sysdba”

set ora_system_id=”system/rsdbsite as sysdba”

set ora_sqlplus=sqlplus

set ora_ocopy=ocopy

set ora_bin_dir=i:\d001\oracle\920\bin

set ora_home=i:\d001\oracle\920\database

set ora_back_dir=o:\d902\oracle\%ora_sid%\colddmps

set ora_log_dir=i:\d002\oracle\%ora_sid%\utillogs\cb

set ora_utl_dir=i:\d002\oracle\%ora_sid%\utilitys\cb

set ora_vbs_dir=i:\d002\oracle\vbs

set ora_recv_dir=i:\d002\oracle\%ora_sid%\utilitys\recv

 

###set init_ora=%ora_home%\spfile%ORACLE_SID%.ora

set init_ora=%ora_home%\init%ORACLE_SID%.ora

set pwd_ora=%ora_home%\pwd%ORACLE_SID%.ora

 

set cb_cold_backup_log=%ora_log_dir%\cb_cold_backup.log

set save_cb_cold_backup_log=%ora_log_dir%\save_cb_cold_backup.log

set cb_ping_db_log=%ora_log_dir%\cb_ping_db.log

set cb_recv_log=%ora_log_dir%\cb_recv.log

set cb_recv_dat=%ora_recv_dir%\cb_recv.dat

set email=dba_ora_offshore@bp.com

rem set email2=dba_ora_offshore@bp.com

rem set email2=dba_ora_onshore@bp.com

set email_message=

set search_for=”%ORACLE_SID%”

set search_for2=”Statement processed”

set search_for3=”ORACLE instance shut down”

set search_for4=”Database opened”

set line=—————————————————————————

set star=*

set error_count=0

 

 

del %ora_log_dir%\cb*.*

 

echo %line% > %cb_cold_backup_log%

echo %line% >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

 

now Cold Backup START for %tns% database >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

echo This is: %0 script >> %cb_cold_backup_log%

 

echo %star% >> %cb_cold_backup_log%

echo %line% >> %cb_cold_backup_log%

echo %line% >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

 

rem ———————————————————————————————

rem — . . . Checking if database %ORACLE_SID% is up

rem ———————————————————————————————

echo . . . Checking if database %ORACLE_SID% is up >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

 

CALL %ora_bin_dir%\%ora_sqlplus%.exe -s %ora_system_id% @%ora_utl_dir%\cb_ping_db.sql

 

CALL %ora_vbs_dir%\upper_case.bat %search_for%

set search_for=%RET%

 

type %cb_ping_db_log% | find.exe %search_for% > nul

 

IF %errorlevel% EQU 0 goto :SKIP0

set /a error_count=error_count+1

set email_message=ALERT: database %tns% is DOWN – Cold Backup terminating!

echo ALERT: database %tns% is DOWN – Cold Backup terminating! >> %cb_cold_backup_log%

goto :END

 

 

rem ———————————————————————————————

rem — . . . Archive log list

rem ———————————————————————————————

 

:SKIP0

 

echo . . . Proceeding with Cold Backup >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

echo %line% >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

echo . . . Archive log list >> %cb_cold_backup_log%

 

CALL %ora_bin_dir%\%ora_sqlplus%.exe -s %ora_sys_id% @%ora_utl_dir%\cb_archive_log_list.sql

 

echo %star% >> %cb_cold_backup_log%

type %ora_log_dir%\cb_archive_log_list.log >> %cb_cold_backup_log%

 

echo %star% >> %cb_cold_backup_log%

echo %line% >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

 

rem ———————————————————————————————

rem — . . . Building the file list

rem ———————————————————————————————

CALL %ora_bin_dir%\%ora_sqlplus%.exe -s %ora_system_id% @%ora_utl_dir%\cb_file_list.sql

echo . . . Building the file list >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

type %ora_log_dir%\cb_file_list.log >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

echo . . . See %ora_log_dir%\cb_file_list.log >> %cb_cold_backup_log%

 

rem ———————————————————————————————

 

 

rem ———————————————————————————————

rem — . . . Shutting down database %ORACLE_SID% immediate

rem ———————————————————————————————

echo %star% >> %cb_cold_backup_log%

echo %line% >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

echo . . . Shutting down database %ORACLE_SID% immediate >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

 

CALL %ora_bin_dir%\%ora_sqlplus%.exe -s %ora_sys_id% @%ora_utl_dir%\cb_shutdown.sql

type %ora_log_dir%\cb_shutdown.log >> %cb_cold_backup_log%

 

type %ora_log_dir%\cb_shutdown.log | find.exe %search_for3% > nul

 

IF %errorlevel% EQU 0 goto :SKIP1

set /a error_count=error_count+1

set email_message=ALERT: Error shutting down %tns% database – Cold Backup terminating!

echo ALERT: Error shutting down %tns% database – Cold Backup terminating! >> %cb_cold_backup_log%

goto :END

 

rem ———————————————————————————————

rem — . . . Starting Oracle file backups

rem ———————————————————————————————

 

:SKIP1

 

echo %star% >> %cb_cold_backup_log%

echo %line% >> %cb_cold_backup_log%

echo . . . Starting Oracle file backups >> %cb_cold_backup_log%

echo %line% >> %cb_cold_backup_log%

 

FOR /f %%I in (%ora_log_dir%\cb_file_list.log) DO (@CALL %ora_utl_dir%\cb_file_backup.bat %%I) & (echo %%I >> %cb_cold_backup_log%) & (echo %%I >> %cb_recv_log%)

 

IF %error_count% NEQ 0 goto :END

 

rem ———————————————————————————————

rem — . . . Backing up the %init_ora% and %pwd_ora% files

rem ———————————————————————————————

echo %star% >> %cb_cold_backup_log%

echo %line% >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

echo . . . Backing up the init%ORACLE_SID%.ora and pwd%ORACLE_SID%.ora files >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

 

xcopy %init_ora% %ora_back_dir%\ /h/f/y >> %cb_cold_backup_log%

xcopy %pwd_ora% %ora_back_dir%\ /h/f/y >> %cb_cold_backup_log%

 

rem ———————————————————————————————

rem — . . . Startup open database %ORACLE_SID%

rem ———————————————————————————————

echo %star% >> %cb_cold_backup_log%

echo %line% >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

echo . . . Startup open database %ORACLE_SID% >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

 

CALL %ora_bin_dir%\%ora_sqlplus%.exe -s %ora_sys_id% @%ora_utl_dir%\cb_startup.sql

type %ora_log_dir%\cb_startup.log >> %cb_cold_backup_log%

 

type %ora_log_dir%\cb_startup.log | find.exe %search_for4% > nul

 

IF %errorlevel% EQU 0 goto :SKIP2

set /a error_count=error_count+1

set email_message=ALERT: Error starting %tns% database – Cold Backup terminating!

echo ALERT: Error starting %tns% database – Cold Backup terminating! >> %cb_cold_backup_log%

goto :END

 

rem ———————————————————————————————

 

rem ———————————————————————————————

rem — . . . Backing up the control file

rem ———————————————————————————————

:SKIP2

 

echo %star% >> %cb_cold_backup_log%

echo %line% >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

echo . . . Backing up the control file >> %cb_cold_backup_log%

CALL %ora_bin_dir%\%ora_sqlplus%.exe -s %ora_sys_id% @%ora_utl_dir%\cb_backup_control_file.sql

erase %ora_back_dir%\prev_backup_control_file.ctl

move %ora_back_dir%\backup_control_file.ctl %ora_back_dir%\prev_backup_control_file.ctl

move %ora_home%\backup_control_file.ctl %ora_back_dir%\backup_control_file.ctl

 

rem ———————————————————————————————

rem — . . . Archive log list

rem ———————————————————————————————

echo %star% >> %cb_cold_backup_log%

echo %line% >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

echo . . . Archive log list >> %cb_cold_backup_log%

CALL %ora_bin_dir%\%ora_sqlplus%.exe -s %ora_sys_id% @%ora_utl_dir%\cb_archive_log_list.sql

echo %star% >> %cb_cold_backup_log%

type %ora_log_dir%\cb_archive_log_list.log >> %cb_cold_backup_log%

 

rem ———————————————————————————————

rem — . . . Building the recovery script

rem ———————————————————————————————

echo %star% >> %cb_cold_backup_log%

echo %line% >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

echo . . . Building the recovery script >> %cb_cold_backup_log%

 

echo %line% > %cb_recv_dat%

echo — . . . Remove the datasets below that you do not want to restore >> %cb_recv_dat%

echo %line% >> %cb_recv_dat%

 

FOR /f %%Z in (%cb_recv_log%) DO (@CALL %ora_utl_dir%\cb_build_recv_file.bat %%Z)

 

echo %star% >> %cb_cold_backup_log%

echo . . . See %ora_recv_dir%\cb_recv.dat >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

 

rem ———————————————————————————————

rem — . . . End Cold Backup

rem ———————————————————————————————

 

:END

 

echo %line% >> %cb_cold_backup_log%

echo %line% >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

now Error_count=%error_count% %email_message% >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

now Cold Backup END >> %cb_cold_backup_log%

echo %star% >> %cb_cold_backup_log%

echo %line% >> %cb_cold_backup_log%

echo %line% >> %cb_cold_backup_log%

type %cb_cold_backup_log% >> %save_cb_cold_backup_log%

 

rem ———————————————————————————————

rem — . . . If an error was detected, send an e-mail

rem ———————————————————————————————

 

IF %error_count% EQU 0 goto :EOF

cscript.exe %ora_vbs_dir%\sendmailattach.vbs -t %email% -f %email% -s “Alert: %tns% Cold Backup Failed!” -b ” %email_message%” -a %cb_cold_backup_log%

If {%email2%}=={} goto :EOF

cscript.exe %ora_vbs_dir%\sendmailattach.vbs -t %email2% -f %email2% -s “Alert: %tns% Cold Backup Failed!” -b ” %email_message%” -a %cb_cold_backup_log%

:EOF

 

Posted in backup and recovery, Scripts | Tagged: , , | Leave a Comment »

 
%d bloggers like this: