Thursday, March 19, 2009

Window Backup Deletion script will delete when Database is open only

test.sql=
spool test.txt
set head off
set term off
set feed off
select status from v$instance;
spool off
exit
=
test.bat=
sqlplus /********@DBNAME @test.sql
TIMEOUT 4
IF EXIST test.txt (
FOR /F " skip=1 delims== " %%i in (test.txt) do (set t1=%%i)
del test.txt
SET DIRPATH=I:\TEST_BACKUP
) ELSE (exit)
IF %t1% EQU OPEN (
I:
cd %DIRPATH%
del DB_NAME_export_old.dmp
del DB_NAME_export_old.log
rename DB_NAME_export.dmp DB_NAME_export_old.dmp
rename DB_NAME_export.log DB_NAME_export_old.log
exp /********@DBNAME file=%DIRPATH%\DB_NAME_export.dmp log=%DIRPATH%\DB_NAME_export.log owner=ABC
)
=