How to Back up IIS 7 and 7.5 with AppCmd

As a follow up to my previous post regarding a GUI for backing up IIS, I thought it pertinent to cover how to back it up using the command line or PowerShell. This is a slightly more in-depth task than the earlier described method. There are four commands as part of the AppCmd backup module. These are list, add, restore and delete. AppCmd is located in %windir%\system32\inetsrv. You should set-location or cd to this directory before attempting to execute any of the commands below, or they will fail.

AppCmd Add Backup

This method allows you to take a new backup of IIS. Execute the command as follows:

C:\> appcmd add backup "backupname"

This will create a new backup within IIS of your configuration with the title backupname. You can then use the following command to restore it:

AppCmd Restore Backup

This method allows you to restore an existing backup of IIS. Execute the command as follows:

C:\> appcmd restore backup "backupname"

This will restore the backup called “backupname” from within IIS. Note that IIS will be restarted during this process. You can tell AppCmd not to restart IIS by issuing the following parameter on the end of the command: /stop:false.

AppCmd List Backup

This command will allow you to list all stored backups. Issue as follows:

C:\> appcmd list backup

This command can be used to find backups you wish to restore or delete.

AppCmd Delete Backup

To purge an existing backup, simply run:

C:\> appcmd delete backup "backupname"

As is evident, this buried tool is quite useful for anyone making significant changes to an IIS install. For further information, you can always run

C:\> appcmd backup /?

and for each individual tool a

C:\> appcmd add backup /?

I hope this eases the pain of the otherwise complicated IIS backup situation.

Written on December 21, 2010