【发布时间】:2014-04-24 12:11:39
【问题描述】:
我启动了一个脚本--command=STATISTICS --statdata=SAVEPOINTS > C:\Safepoints.txt
,它会生成这样的输出。
Page count for each save point version:
0: version=0, status=3, ts=2014-03-18 16:24:51.764, page count=68861
1: version=1, status=3, ts=2014-03-18 17:49:25.622, page count=68861
2: version=2, status=3, ts=2014-03-19 05:00:10.467, page count=68925
3: version=3, status=2, ts=2014-03-20 14:05:53.267, page count=2744
4: version=4, status=3, ts=2014-03-20 15:08:40.607, page count=68859
5: version=5, status=3, ts=2014-03-21 05:00:10.527, page count=68926
我的想法是,读取 C:\Safepoint.txt 并检查是否存在多个状态=3(完整备份)的文件,而不是保留最新文件,否则启动这样的新命令
--command=DELETE_SAVEPOINTS 0-4
我修改了脚本如下,但它卡在
之前for 循环后 > %mytempfile%
@echo on
set last=-1
set mytempfile=%TEMP%\%random%.out
%ORACLE%\bin\OracleDatabase.bat --dbtype=ORACLE --database=orca --hostname=test.ora.db --port=5645 --user=sa --password=***** --command=STATISTICS --statdata=SAVEPOINTS > %mytempfile%
for /f "tokens=1 delims=: " %%a in ('type %mytempfile% ^| find "status=3" ') do set /a last=%%a
for /f "tokens=1 delims=: " %%a in ('type %mytempfile% ^| find "status=3" ') do (
if %last% neq %%a (
%Oracle%\bin\OracleDatabase.bat --dbtype=ORACLE --database=orca --hostname=test.ora.db --port=5645 --user=sa --password=***** --command=DELETE_SAVEPOINTS %%a
)
)
del /q %mytempfile%
【问题讨论】:
标签: oracle shell batch-file scripting backup