on Windows 2003。不論加密與否都不影響還原

backup.bat
@echo off

@rem =========================================
@rem Author: flyfox 20121102
@rem 使用需知
@rem 1. 需安裝 IIS 6
@rem 2. 需安裝 7-zip
@rem 3. IIS 備份檔位於 D:\Backup\
@rem 4. 需變更 cscript 為預設執行的 VBScript
@rem =========================================

@rem =========================================
@rem 設定各路徑變數
@rem =========================================
@set DDir=D:\Backup\
@set zip="C:\Program Files\7-Zip\7z.exe"
@set batlog=D:\bat\log
@set pi=C:\WINDOWS\system32\ping.exe
@md %DDir%
@md %batlog%

@rem =========================================
@rem 設定備份檔名稱、log檔名稱
@rem =========================================
@set file=%computername%-iisbackup.xml
@set zipfile=%computername%-iisbackup-%date:~0,4%%date:~5,2%%date:~8,2%.7z
@set log=D:\bat\log\log-%date:~0,4%%date:~5,2%%date:~8,2%-%time:~0,2%%time:~3,2%%time:~6,2%.txt
@set log=%log: =0%

@rem =========================================
@rem 備份 IIS 設定檔
@rem =========================================
@if exist %DDir%%file% (del /F /S /Q %DDir%%file%)
@iiscnfg /export /f %DDir%%file% /sp /LM/W3SVC /children /inherited

:compress
@rem =========================================
@rem 設定壓縮 IIS 備份檔
@rem =========================================
@echo ================ start ================== > %log%
@echo Date: %date% Time: %time% >> %log%
@if exist %DDir%%zipfile% (del /F /S /Q %DDir%%zipfile%)
@if exist %DDir%%file% (%zip% a -mmt=4 -mx=9 %DDir%%zipfile% -mhe %DDir%%file% && echo. >> %log%) else (goto noxml)
@echo Compress Success! >> %log%
@%pi% 127.1 -n 3 -w 1000 > nul
@start D:\bat\SendIISConfig.exe >> %log%
@goto close

:noxml
@rem =========================================
@rem 找不到 IIS 備份檔
@rem =========================================
@echo can not find IIS config file! >> %log%
@forfiles /P noxml /S /M *.* /D -30 /C "cmd /c del @path"
@exit
@echo on

:close
@exit
@echo on

arrow
arrow
    全站熱搜

    flyfox 發表在 痞客邦 留言(0) 人氣()