How to fix: appcmd restore backup CFGHISTORY_########## return Error ( hresult:80070002, message: Command execution failed. The system cannot find the file specified.)?

Jen J 0 Reputation points
2025-08-27T16:47:28.6133333+00:00

The file applicationhost.config is missing from C:\windows\system32\inetsrv\config folder with unknown reason. when I try to restore from history backup in evaluated prompt command, it gives error 80070002. I can manually copy the file to config folder neither. The user administrator has permission of full control to the folder.

Windows development | Internet Information Services
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Tom Tran (WICLOUD CORPORATION) 525 Reputation points Microsoft External Staff
    2025-08-28T03:39:20.9333333+00:00

    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:


    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 under system.applicationHost.

    Reference:


    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.