Applies to: Windows Server 2019, Windows Server 2022 and Windows Server 2025, subject to the workload and edition requirements below.
Know the boundary of an AppCmd backup
AppCmd backs up IIS server configuration so an administrator can recover from an unwanted global configuration change. A named backup captures ApplicationHost.config and related server-level IIS state. It is useful before changing sites, bindings, pools or installed components that alter IIS configuration. It is not a complete website backup and should never be presented as a single-file disaster-recovery solution for the web server.
Application content, databases, distributed web.config files, certificate private keys, external secrets and application runtimes need separate protection. A backup that restores the old binding still cannot serve HTTPS if its certificate and key are missing. This guide creates and verifies a named configuration backup, explains a controlled same-server restore, and identifies what must accompany it for broader recovery or migration.
Inventory the affected sites and recovery dependencies
Determine whether the proposed change affects one site or global IIS configuration. A global restore can revert changes made by other administrators after the selected backup, including unrelated sites. Coordinate the maintenance window and identify the application owners before treating restore as an easy undo button. Record the current site and pool states and any binding or identity being changed.
Check whether the server uses IIS Shared Configuration or a centrally managed deployment system. Shared configuration and its encryption keys require their own supported backup and recovery design; a local AppCmd invocation should not be assumed to protect every remote dependency. Preserve the application deployment version and data-schema compatibility too. Reverting a pool setting does not revert a database migration.
Import-Module WebAdministration
Get-Website | Select-Object Name,Id,State,PhysicalPath,Bindings
Get-ChildItem IIS:\AppPools | Select-Object Name,State
Get-WebBinding
Get-Service W3SVC,WASStore recovery records outside the web server as well as locally. If the operating-system disk fails, a configuration backup left only under that same disk’s inetsrv directory is unavailable precisely when it is needed.
Create a uniquely named backup and check the exit code
Use an elevated Windows PowerShell session and the AppCmd executable installed with IIS. The call operator invokes the full executable path safely, including when path expansion is involved. Use a descriptive name containing a timestamp and change purpose so the correct recovery point can be identified later.
$appcmd = Join-Path $env:windir 'System32\inetsrv\appcmd.exe'
$backupName = 'Before-PortalBinding-' + (Get-Date -Format 'yyyyMMdd-HHmmss')
& $appcmd add backup $backupName
if ($LASTEXITCODE -ne 0) { throw 'AppCmd backup failed; do not proceed with the change.' }
& $appcmd list backupsA successful result should identify the new BACKUP object. Check the exit code immediately, because a later native command replaces it. Listing backups confirms the named object is discoverable; it does not prove the application content or external dependencies were captured. If creation fails, investigate permissions, configuration validity and storage before making the planned change. Do not proceed on the assumption that the configuration-history service will certainly cover it.
Inspect and protect the backup files
Named AppCmd backups normally reside beneath the IIS inetsrv backup directory, organized by backup name. Confirm the actual object and expected configuration files. Protect the directory because configuration may include sensitive connection or identity information, even when certain values are encrypted. Encryption of some fields does not make an unrestricted configuration export safe to share.
$backupPath = Join-Path $env:windir ('System32\inetsrv\backup\' + $backupName)
Get-ChildItem -LiteralPath $backupPath
Get-Item -LiteralPath (Join-Path $backupPath 'applicationHost.config') |
Select-Object FullName,Length,LastWriteTime
Get-FileHash -LiteralPath (Join-Path $backupPath 'applicationHost.config')Record the backup name, creation time, server build and intended change. Copy or protect the backup through the approved off-server backup process, preserving required access controls. A hash can help detect an unintended file change during handling, but it does not establish that every setting is logically correct or that a different server can decrypt machine-bound values. Treat portability and same-server rollback as separate objectives.
Back up the pieces AppCmd does not include
Protect each site’s physical content and its web.config files through the application backup or deployment system. Include uploaded files, generated data and external storage where applicable. Protect databases using the application’s consistency requirements rather than copying live database files as ordinary web content. Record the application release and compatible schema version.
Export or otherwise protect HTTPS certificates and private keys through the approved PKI process, with strong access controls and separately managed recovery passwords. Inventory bindings and certificate thumbprints so the correct key can be associated during recovery. Include custom runtime installation packages, hosting bundles, modules, scheduled tasks and service dependencies in the recovery plan.
Custom application-pool or virtual-directory credentials can involve machine-specific IIS encryption keys. A copied ApplicationHost.config is therefore not automatically a portable migration package. Use the documented IIS migration or shared-configuration key procedures when moving servers. Do not decrypt secrets into a public text file to make the backup easier to understand.
Choose and perform a controlled restore
Before restoring, preserve the current configuration under a new name and compare the selected backup’s timestamp and scope with the incident. Confirm that reverting all server-level changes since that point is acceptable. Arrange a maintenance window: AppCmd restore is a server-wide IIS configuration operation that can stop or interrupt service, not a transparent per-site patch.
& $appcmd list backups
& $appcmd add backup ('Before-Restore-' + (Get-Date -Format 'yyyyMMdd-HHmmss'))
# Set this to the reviewed, existing backup name:
$restoreName = 'REPLACE_WITH_APPROVED_BACKUP_NAME'
& $appcmd restore backup $restoreName
if ($LASTEXITCODE -ne 0) { throw 'Restore failed; preserve the output and investigate.' }Do not select a backup solely because it is the oldest or newest. A known-good point must correspond to the desired site, identity and binding state. If only one reviewed property is wrong, a targeted correction may have less impact than a global restore. Keep the change and restore outputs with the incident record so later validation can distinguish what was requested from what completed.
Validate service and application acceptance after restore
Check IIS services, site and pool state, bindings and certificate associations after the operation. Start only the components that the baseline says should be running, and investigate an unexpected stopped state rather than issuing an indiscriminate reset. Compare the restored configuration with the intended backup, then test real application paths from representative clients.
Get-Service W3SVC,WAS
Get-Website | Select-Object Name,State,PhysicalPath,Bindings
Get-WebAppPoolState -Name 'PortalPool'
netsh http show sslcert
Invoke-WebRequest -Uri 'https://portal.corp.example/' -UseBasicParsingVerify authentication, static and dynamic content, data writes, backend connectivity and logging as appropriate. Check that unrelated sites still have their intended bindings and identities. A restored configuration can reference a deleted folder, missing certificate or unavailable runtime, so a success message is only the beginning of recovery acceptance. Confirm with the application owner that the correct business behaviour has returned.
Troubleshoot restore failures and manage retention
For a failed restore, preserve the exact AppCmd error, current configuration and selected backup. Inspect permissions, file integrity, shared-configuration state and machine-specific encrypted dependencies. Do not manually overwrite global configuration repeatedly while WAS or another management system is changing it. A restore loop can erase the most useful evidence and revert unrelated repairs.
Keep a retention policy for named and automatic history backups and protect a known recovery set off-server. Delete old backups only after checking change-record and recovery requirements. Rehearse recovery on an isolated representative system using the complete dependency set, with no claim that a local configuration backup alone demonstrates disaster recovery. A useful AppCmd backup is a well-identified configuration checkpoint inside a broader, tested application recovery process.
Related guidance and official references
Create an IIS site and pool; Manage the HTTPS binding; Review application pool identities; Create a server backup.