How To: Backup IIS7 ApplicationHost.config and Settings

Internet Information Services 7 (IIS7) doesn’t use metabase-like file from IIS6. Instead the settings and configuration are stored in schema files and applicationHost.config files.

Since the configuration files are different, the old IIS6 tools will not be able to backup IIS7 settings.

This is the new script that you can use to backup your IIS7 web servers.

1. Using notepad or any text editor create a file backupiis7.cmd

2. Insert the following code and save the file:

@echo off
cls

pushd "%WinDir%\System32\inetsrv"

echo.| date | find /i "current">datetime1.tmp
echo.| time | find /i "current">datetime2.tmp

for /f "tokens=1,2,3,4,5,6" %%i in (datetime1.tmp) do (
  echo %%n>datetime1.tmp
)
for /f "tokens=1,2,3,4,5,6" %%i in (datetime2.tmp) do (
  echo %%m>datetime2.tmp
)
for /f "delims=/ tokens=1,2,3" %%i in (datetime1.tmp) do (
  set TMPDATETIME=%%k%%i%%j
)
for /f "delims=:. tokens=1,2,3,4" %%i in (datetime2.tmp) do (
  set TMPDATETIME=D%TMPDATETIME%T%%i%%j%%k%%l
)

appcmd add backups %TMPDATETIME%

del datetime1.tmp
del datetime2.tmp

set TMPDATETIME=

popd
echo.

3. The IIS7 configuration will be backed up at the following path:

C:\Windows\System32\inetsrv\backup

NOTE: you can also use Task Scheduler to automate backups.

1 thought on “How To: Backup IIS7 ApplicationHost.config and Settings”

Comments are closed.