Oracle 備份並刪除以前一定時間的備份

來源:互聯網
上載者:User

@echo off 

echo 正在備份資料庫檔案,請稍等...... 

exp.exe report/ok@report file=d:/reportBack/report%date%.dmp log=d:/reportBack/report%date:~0,10%.log 

 

echo 正在刪除備份檔案,請稍等...... 

rem 需要Win2003/Vista/Win7系統內建的forfiles命令的支援

rem forfiles /p "d:/reportBack" /d -2 /c "cmd /c del /f @path"

 

rem 指定待刪除檔案的存放路徑

set SrcDir=d:/reportBack

rem 指定天數

set DaysAgo=2

for /f "skip=2 delims=" %%a in ('reg query "HKEY_CURRENT_USER/Control Panel/International" /v sShortDate') do (

  set "RegDateOld=%%a"

)

set RegDateOld=%RegDateOld:~-8%

reg add "HKEY_CURRENT_USER/Control Panel/International" /v sShortDate /t REG_SZ /d yyyy-M-d /f>nul

>"%temp%/DstDate.vbs" echo LastDate=date()-%DaysAgo%

>>"%temp%/DstDate.vbs" echo FmtDate=right(year(LastDate),4) ^& right("0" ^& month(LastDate),2) ^& right("0" ^& day(LastDate),2)

>>"%temp%/DstDate.vbs" echo wscript.echo FmtDate

for /f %%a in ('cscript /nologo "%temp%/DstDate.vbs"') do (

  set "DstDate=%%a"

)

set DstDate=%DstDate:~0,4%-%DstDate:~4,2%-%DstDate:~6,2%

for /r "%SrcDir%" %%a in (*.*) do (

  if "%%~ta" leq "%DstDate%" (

  if exist "%%a" (

  del /f /q "%%a"

  )

  )

)

 

reg add "HKEY_CURRENT_USER/Control Panel/International" /v sShortDate /t REG_SZ /d %RegDateOld% /f>nul

 

@echo 刪除成功!

@echo 備份成功!

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.