on Windows 2008。
restore.bat
@echo off
@rem =========================================
@rem Author: flyfox 20121105
@rem 使用需知
@rem 1. 需安裝 IIS 7
@rem 2. 需安裝 7-zip
@rem 3. 需將要還原的設定檔解壓縮至 D:\Backup\
@rem =========================================
@rem =========================================
@rem 設定各路徑變數
@rem =========================================
@set SDir=C:\Windows\System32\inetsrv\
@set DDir=D:\Backup\
@set batlog=D:\bat\log
@rem =========================================
@rem 設定備份檔名稱、log檔名稱
@rem =========================================
@set file=%computername%
@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 =========================================
@echo ================ start ================== > %log%
@echo Date: %date% Time: %time% >> %log%
@cd %SDir% >> %log%
@if exist %SDir%backup\%file% (rd /S /Q %SDir%backup\%file% && echo rd IIS old backup >> %log%)
@goto restore
:restore
@rem =========================================
@rem 移動新 IIS 備份檔並還原設定
@rem =========================================
@if exist %DDir%%file% (xcopy /E /I /V /C /Y %DDir%%file% %SDir%backup\%file% && echo. >> %log%) else (goto nofile)
@appcmd restore backup %file% >> %log%
@echo IIS Restore Success. >> %log%
@rd /S /Q %DDir%%file% >> %log%
@goto close
:nofile
@rem =========================================
@rem 找不到 IIS 備份檔
@rem =========================================
@echo Can't find IIS config file! >> %log%
@forfiles /P noxml /S /M *.* /D -30 /C "cmd /c del @path"
@exit
@echo on
:close
@exit
@echo on
留言列表