The process to backup and restore IIS on Windows Server 2016 is identical to the process used in previous versions of IIS.
On the source server perform the following tasks:
- Backup all Website Files.
- Export any SSL certificates you may have installed.
- Backup the IIS configuration.
Perform the following tasks on the destination server:
- Restore all Website Files.
- Import any SSL certificates that are required.
- Restore the IIS configuration.
There are a few key dependencies that you must take into consideration.
- Both servers must run the same version of IIS.
- The configuration of IIS must be the same on both servers.
- The steps described above must be executed in the order stated i.e. certificates must be imported before the IIS configuration is restored.
- If you are not running the web server as part of an Active Directory domain, you must pay special attention to the user accounts configured. Specifically the application pool user account which must have access to the necessary website source files.
I have deployed a very simple HTML site to demonstrate this so I will only be performing steps 1 and 3 on each server as I have no SSL certificates installed. The demo website I am using can be downloaded from Initializr. If you have not used this resource before, go check it out as it is a great way to get a website started quickly and efficiently.
Backing up and Restoring Website Files
To backup the website files simply navigate to the location on the file system where the files are stored.
Zip all the files for easier transportation.
Copy and extract all files on the destination server.
Backing up and Restoring the IIS Configuration
Navigate to C:\Windows\System32\inetsrv on the source server and run the following command to create a backup. Remember to run this as an Administrator.
appcmd add backup “<backup name>”
Navigate to C:\Windows\System32\inetsrv\backup where you will find the backup files nicely stored in a folder. Zip the folder for easier transportation and copy it to the same location on the destination server.
Extract the backup configuration files.
On the destination server open a command prompt as an Administrator and navigate to C:\Windows\System32\inetsrv and run the following command
appcmd list backup
Your backup should be listed. You may also see some system backups on your list as I have in the example below.
Note that system backup files can be found at C:\inetpub\history
Now all we need to do is run the restore command to finalize and get our migrated site up and running.
The restore command is:
appcmd restore backup “<backup name>”
If all goes well you should see a message stating that the server has “Restored configuration from backup “<backup name”>.