Get the Network Administrators tool pack

Subscribe to our newsletter and get 11 free network administrator tools, plus a 30 page user guide so you can get the most out of them.

Click Here to get your free tools

Recent Posts



Backup up IIS from the command line

Post image for Backup up IIS from the command line

by Steve Wiseman on June 9, 2011 · 12 comments

in Command Line,Tips,Tools,Utility,Windows


Trying something new this week – got a video version of this weeks tip:

Got a question from Linda this week,

“Steve. We have quite a few IIS based web servers and each of them has their own custom configuration. I know how to backup all the files, but is there any way to backup and restore IIS settings from the command line? ”

Great question. When using IIS, you eventually get lots of custom settings hiding in there:

IIS Main View

IIS Stores all of these settings in what as known as the metabase. It keeps track of the home directory, ISAPI filters, what type of files it will process, etc. How to we back this up?

You can back it up manually from the IIS manager:

Manual Backup

But this has a major flaw. It just backs it up to a hidden file on your hard drive. Sure you can find this, and pull it off – but that takes some digging. That won’t help you much when the server is smoking and you want to get another one in its place right away.

How can we automate this process, and be able to grab the file and do what we want with it?

By using a little known VBS file that is included with Windows

It is called IISCnfg.vbs

Before we can use it, get to a command line and type IISCnfg and then enter.

It will give you an error, and then ask if you want to default to use CScript.exe instead of VBScript.exe for your VB Scripts.

CScript Required

Once you say yes, you can start calling it from your batch files or the command line.

There are many options to iiscnfg, but there are a few things that we will require:

-We want to export the settings
-We want all the settings, so we will start at the root and include the children
-We need to set a password on the exported file, or it won’t work on another server (Feature or bug – you decide)
-We want to export the file to a specific location, not the metabase storage area

So here are those requirements translated into arguments:

iiscnfg /export /sp /lm /children /inherited /d [password] /f c:\backup\IISMetabase.bak

The [password] is the password the file will be encrypted with. You will need this to restore it, so don’t forget it!

/sp (Source Path) indicates where in the IIS structure you want to start the backup /lm is at the top of this (I believe lm stands for local machine…someone please write a comment below if I am wrong)

So the above code will take our entire structure and back it up to c:\backup\IISMetabase.bak and then encrypt that file with the password [password]

Put that in your batch file used for backups and you can pull that config any time you want. Keep in mind this only backs up your configuration. Not the files that make up your website or ftp sites.

Later, a new VP of IT walks in and starts plunking around on your web servers

VP Messing with IIS

After he “improved” the system, how do you restore the settings?

You get that metabase file from your backups, and import it using a very similar command line:

iiscnfg /import /dp /lm /sp /lm /children /inherited /d [password] /f c:\backup\IISMetabase.bak

Note the /dp (Destination Path) and /sp (Source path). In my example they point to the same place – the top of the IIS settings tree.

Notice the password – it must be the same as the one used to back it up. If you forgot it your hosed. If you forgot to even set a password you might be OK…as long as it is the same system. Otherwise again, your hosed.

That is all there is to it. One line to backup, and one line to restore.

One more thing…Subscribe to my newsletter and get 11 free network administrator tools, plus a 30 page user guide so you can get the most out of them. Click Here to get your free tools

Related Articles:

{ 12 comments… read them below or add one }

1 John Sithers June 9, 2011 at 9:02 am

Great tip steve. I never even knew this was possible. Been backing up the entire server with the system state, and I missed how with Apachie on Linux I could just copy the website files, and the config files. Now I can do the same with IIS. Thanks a ton.

2 Mike June 9, 2011 at 9:03 am

What about srvr 2008? Will this work on that as well?

3 Steve Wiseman June 9, 2011 at 9:03 am


Glad it helped you out. Been using this for some time on our own websites. Works great if you want to add another server, or even have a staging server with the same exact config.

4 Steve Wiseman June 9, 2011 at 9:04 am

Hello Mike,

I don’t think it will. That will have to be another article. I would have to check, but I would imagine that MS replaced it with a powershell script of some type.

5 Linda T June 9, 2011 at 9:04 am


Thank you for answering my question. It was exactly what I was looking for!

6 Steve Wiseman June 9, 2011 at 9:05 am

No problem…glad I could help

7 Jen Minsk June 9, 2011 at 11:11 am

This is a great tip. Thanks Steve

8 Steve Wiseman June 9, 2011 at 11:12 am

No problem Jen…glad it helped you out.

9 David Chang June 10, 2011 at 3:53 pm

Hi steve. Like the video. Is there anyway to backup just smtp settings?

10 Steve Wiseman June 10, 2011 at 4:15 pm

Hello David,

I believe you could set your sp and dp to /lm/SmtpSvc1 and it will backup the first SMTP instance…if you have more than one I think you would need to use multiple files, ore just backup the whole IIS tree (lm)

11 Mohammed February 8, 2013 at 11:37 am

Hi Steve, Is is possible to import onto a server 2008 (i cannot get iiscnfg to work)Server 2008 has iis 7 installed with iis6 but as i only require the smtp config from the server 2003 box

12 Bill February 19, 2013 at 8:45 pm

Hoping for an answer to Mohammed’s question as I have the same issue.

Leave a Comment

Category Links - Windows Forum - Exchange Forum