Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

 Windows OS Hub / Windows Server 2016 / How to Backup and Restore Websites and IIS configuration

June 8, 2023

How to Backup and Restore Websites and IIS configuration

In this article, we’ll look at how to backup websites, application pools, and IIS web server configuration on Windows Server. You can use an Internet Information Services backup to restore a website in the case of a host server failure, or if you migrate/move a website (and/or IIS configuration) to another server.

Contents:
  • Backing Up IIS on Windows Server
  • Restoring an IIS Configuration on a Different Windows Server Host

Backing Up IIS on Windows Server

Backing up the data and configuration of sites running on an Internet Information Service web server consists of several steps:

  1. Backup IIS website files (by default, IIS site files are stored in %SystemDrive%\inetpub\wwwroot ). This folder must be included in the backup plan. It is enough to copy files all files using your backup tool (you can even use the built-in Windows Server Backup -> select the inetpub directory for backup), or simple BAT/PowerShell scripts. For example, to install WSB and back up the inetpub\wwwroot directory to a shared folder, use the following commands:# Install the Windows server feature using PowerShell;
    Install-WindowsFeature -Name Windows-Server-Backup
    # backup IIS website static files
    wbadmin start backup –backupTarget:\\srv-backup1\backup -include:c:\inetpub\wwwroot -vsscopy
  2. Backup (export) current IIS certificates (you can get the list of SSL certificates on the server using this command: netsh http show sslcert ) You can use PowerShell to backup certificates to a shared network folder in the PFX (Personal Information Exchange) format: dir cert:\localmachine\my | Where-Object { $_.hasPrivateKey } | Foreach-Object { [system.IO.file]::WriteAllBytes("\\srv-backup1\backup\$($_.Subject).pfx",($_.Export('PFX', 'secret')) ) } iis ssl certificate bindings, export cert pfx
  3. Backup IIS configuration (settings).

You can backup the IIS configuration using the built-in appcmd tool. Open a command prompt as an administrator  and change directory:

cd c:\Windows\system32\inetsrv

Let’s back up the IIS configuration:

appcmd add backup srv1-iis-backup-2022_03_10

BACKUP object srv1-iis-backup-2022_03_10 added

backup iis configuration using the appcmd tool

Appcmd creates a folder in the c:\Windows\system32\inetsrv\backup directory with the name of your backup. It contains the following files:

  • administration.config
  • applicationHost.config
  • MBSchema.xml
  • MetaBase.xml
  • redirection.config

iis backup folder

It remains to copy this directory to the backup storage device.

On Windows Server 2019/2016, you can use the built-in PowerShell cmdlet to backup IIS instead of appcmd:

Backup-WebConfiguration -Name MyBackup202203

This cmdlet also exports the current IIS settings to $env:Windir\System32\inetsrv\backup.

Restoring an IIS Configuration on a Different Windows Server Host

You can restore your IIS configuration from a backup to the same server or to a different host. Let’s say you need to restore the IIS configuration on a different Windows Server host.

Copy the IIS backup directory to the same folder (c:\windows\system32\backup) on the target server.

To display a list of all available IIS configuration backups, run the command:

appcmd list backup

The copied backup should appear in the list of available ones. Restore the IIS config from a backup:

appcmd restore backup /stop:true srv1-iis-backup-2022_03_10

restore iis config files from a backup with appcmd

The “Restored configuration from backup srv1-iis-backup-2022_03_10 means that the IIS configuration has been successfully restored.

The /stop:true option forces IIS to stop before restoring.

Restore-WebConfiguration -Name srv1-iis-backup-2022_03_10

Note. There are entries like BACKUP “CFGHISTORY_0000000001” in the list of available backups. These are IIS configuration backups created automatically and located in the \inetpub\history directory. Automatic backup features appeared in IIS 7+: the changes to ApplicationHost.config made through IIS Manager are tracked, the 10 latest backups are stored, and the file is checked for changes every 2 minutes.

To delete a previous backup, run the command:

appcmd.exe delete backup BackupName

Note. List of important restrictions and key points:

  • The same IIS version has to be used on both servers. You can check your version of IIS in the registry using PowerShell: get-itemproperty HKLM:\SOFTWARE\Microsoft\InetStp\ | select setupstring,versionstring In my case, this is IIS 10.0 check iis version with powershell
  • If IIS application pools are not run from the built-in accounts, they must be available on the target IIS host.
  • Before restoring IIS, you must import any SSL certificates you use to the new server.

You can also backup your IIS web server using the msdeploy package (Web Deployment Tool). Download and install the msdeploy package on your IIS host and on the target backup host (https://www.microsoft.com/en-us/download/details.aspx?id=43717).

To create an IIS backup (with all sites if multiple sites are running on IIS) to a remote Windows host 192.168.100.112 via webdeploy, the following command can be used:

msdeploy -verb:sync -source:webServer,computername=192.168.100.112 dest:package=c:\Backup\IIS\server1_iis_backup.zip

You can also backup an individual IIS website:

msdeploy –verb:sync -source:contentPath="site_name.com",computername=192.168.100.112 -dest:package=c:\Backup\IIS\site_name.zip

Or copy only static website files from the specified directory:

msdeploy –verb:sync –source:dirPath="c:\inetpub\wwwroot\site_name",computername=192.168.100.112 -dest:package=c:\Backup\IIS\site_name_static_files.zip

3 comments
14
Facebook Twitter Google + Pinterest
PowerShellWindows Server 2016Windows Server 2019
previous post
Configuring Central Store for Group Policy ADMX Templates
next post
Managing Hyper-V Virtual Machines with PowerShell

Related Reading

How to Convert (Upgrade) Windows Server Evaluation to...

March 15, 2024

Using DISM to Check and Repair Windows Image

March 15, 2024

Enable Two-Factor Authentication (2FA) in Windows with MultiOTP

March 15, 2024

How to Install and Configure Free Hyper-V Server...

March 16, 2024

Poor Network Performance on Hyper-V VMs in Windows...

February 20, 2023

High Non-Paged Pool Memory Usage (Leak) in Windows

August 30, 2021

Tracking and Analyzing Remote Desktop Connection Logs in...

March 15, 2024

How to Install and Activate the RDS Licensing...

February 13, 2024

3 comments

Scott Turner February 20, 2017 - 9:26 pm

Thank you for writing this. Depending on user needs for ongoing IIS and SQL Server configuration remediation, rollback, backup and recovery, a commercial solution like Orcaconfig may make sense.

Orca takes configuration inventory snapshots (every few minutes or so) and stores the current configurations of the Production environment. In a recovery or disaster scenario where you lose access to Production and need to fail over to DR, your Production configuration settings already stored automatically.

Reply
Daniel MOUSSORO October 8, 2021 - 11:14 am

Thank you Very much. This tutorial has been very useful to me.

Reply
faig July 26, 2023 - 9:47 am

Not a complete backup. Author didn’t write the restoration steps.

Reply

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • Configuring Windows Protected Print Mode (WPP)

    May 19, 2025
  • Map a Network Drive over SSH (SSHFS) in Windows

    May 13, 2025
  • Configure NTP Time Source for Active Directory Domain

    May 6, 2025
  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Install and Manage Windows Updates with PowerShell (PSWindowsUpdate)
  • How to Download Offline Installer (APPX/MSIX) for Microsoft Store App
  • How to Delete Old User Profiles in Windows
  • Fix: Remote Desktop Licensing Mode is not Configured
  • Configuring Port Forwarding in Windows
  • How to Install Remote Server Administration Tools (RSAT) on Windows
  • Start Menu or Taskbar Search Not Working in Windows 10/11
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top