Hi Jen J,
The error you are encountering:
appcmd restore backup CFGHISTORY_########## Error (HRESULT: 80070002): The system cannot find the file specified.
This is a configuration integrity issue, not just a temporary glitch. It means IIS cannot locate the applicationhost.config
file in the expected backup folder or in the live configuration directory (C:\Windows\System32\inetsrv\config
).
This error typically occurs when:
- The backup folder exists but is missing required files.
- The
applicationhost.config
file was deleted or quarantined by antivirus software. - A failed Windows Update or IIS reinstallation caused partial overwrite.
- Disk corruption or manual deletion affected the config folder.
You can check these options out when you have the time:
Verify Backup Integrity
Check the contents of:
C:\inetpub\history\CFGHistory_##########
Ensure it contains:
-
applicationhost.config
-
administration.config
-
redirection.config
Use:
appcmd list backups
appcmd restore backup <valid-backup-name>
Recover from Another Source
If no valid backup:
- Copy
applicationhost.config
from a matching IIS version server. - Or extract from a system image backup (e.g., Veeam, Windows Server Backup).
Reference: CodeProject – Recover IIS When ApplicationHost.config is Ruined
Rebuild Configuration
If recovery isn’t possible:
- Recreate sites and app pools using IIS Manager or
appcmd
. - Restart IIS:
iisreset
Reference: IIS Backup and Restore – Sysadmins of the North
You can also prevent future losses:
Enable Configuration History
Ensure IIS is keeping automatic backups:
reg add HKLM\Software\Microsoft\InetStp\ConfigurationHistory /v EnableHistory /t REG_DWORD /d 1 /f
Reference:
- Using Configuration History with IIS – Microsoft Learn
- IIS Configuration History Deep Dive – Shane Bart
Automate Backups
You can automate backups using Backup-WebConfiguration
from the WebAdministration module:
Backup-WebConfiguration -Name "AutoBackup_$(Get-Date -Format 'yyyyMMdd_HHmmss')"
This stores backups in:
-
C:\Windows\System32\inetsrv\backup
Reference: Windows OS Hub – IIS Backup and Restore
Audit Folder Access
Enable NTFS auditing on:
-
C:\Windows\System32\inetsrv\config
Track changes via:
-
Applications and Services Logs > Microsoft > Windows > IIS-Configuration > Operational
- Enable logging and set retention.
- Note: manual edits via Notepad are not logged, but changes via AppCmd or IIS Manager are.
Reference: Spiceworks – IIS Auditing Guide
I also find from Microsoft Learn:
- IIS 7+ includes a Configuration History feature that automatically backs up
applicationhost.config
every 2 minutes. - You can customize retention and scan frequency using:
<configHistory maxHistories="15" period="00:00:10" />
- These settings go in
applicationHost.config
undersystem.applicationHost
.
Reference:
- Microsoft Learn – Using Configuration History with IIS 7 and IIS 8
- Shane Bartholomeusz – IIS Configuration History Deep Dive
This is all the information I could find at the moment.
I hope this helps you resolve your issue! If you have any more questions - please feel free to ask, I'll be happy to help.