Scheduled metabase backups

Categories:

IIS can be one of the most configuration intensive server applications in your environment, so it makes especially good sense to ensure you always have a current backup of the metabase which stores all of the configuration directives in IIS. IIS metabase backups are split into two files with the naming convention of MDx and SCx, where MD is the metabase backup, SC is the schema backup and x is the revision number of the backup using values from 0~999. Previously we have covered the topic of backing up and restoring your IIS 6 metbase via the GUI and the command line, and in this guide we'll be using a script to automate this task which is then scheduled to ensure your backups are always up to date.

The script we'll be using in this article is based on the script I used previously in my guide to backing up MySQL automatically using a batch file. What this script basically does is create a backup of your IIS metabase, moves and compresses it to a user defined location, and then emails a user defined email address the results. To do this the script uses two executables to compress and email backup reports, and one VB script which comes with IIS 6 to perform the actual backup. These utilities are;

  • gzip - a command line based compression tool
  • blat - a command line based email client
  • iisback.vbs - script for managing your IIS metabase backups which comes with Windows 2003/ IIS 6.

Download these files along with the iis_backup.bat batch file script from below and using your favorite text editor configure all the options at the top of the batch file where the "ENTER_VALUE_HERE" string is with the values from your own environment. Once complete, save the batch file and it is time to give it a test. Run the iis_backup.bat script by either double clicking on it or running it from a command prompt. Once completed you should find two compressed files in your specified backup directory, and have an email containing a summary of the results.

Once this is complete the only step left is to schedule the backups so that they run automatically at a set time. How often you backup your metabase is entirely up to you, but it should be at least as often as the number of times you modify your IIS environment on average. If you make changes once a month, then there is little worth in backing it up every day, and if you modify it daily there is risk in only backing it up once a month. In this example we'll set the IIS_backup.bat file to run one a week on a Sunday night at 11pm. To do this open a command window and type in;
at 23:00 /every:Su x:\path\to\iis_backup.bat
That is it, your IIS metabase should now have regular backups. If possible try and ensure the backups are not stored on the same hardware as IIS is running on, as backing up the metabase to the same physical machine only really protects you from human error, not catastrophic error. As always feel free to leave any comments, questions or suggestions you might have here or in the forums.

Average rating
(0 votes)
AttachmentSize
iis_backup.bat2.39 KB

Comments

Anonymous's picture

where is the file

the file iis_backup.bat does not seem to exist ..?

Brashquido's picture

Should be ok

Should be ok now.
----------------
Dominic Ryan
4 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

Anonymous's picture

Nice, but some minor glitches

Hi,

Great stuff, thanks!

I'm testing on XP, so "results may vary", as they say.

I just want to say that the time capture uses the variable ii for capture, but mm for construction of the fn string. So, the minute in fn is actually the month.

Also (on XP), the first date variable is never captured. It appears that the For loop only starts capturing after the first delimiter. I will test on 2003 server, but while I'm commenting on the "minute" glitch (not sure you didn't do that on purpose), I figured I'd ask.

Thanks,

Steve

Anonymous's picture

re: Glitches

Hi again,

Just found the problem with the date parser.

The batch file contains the line: for /F "tokens=2-4...

It works 100% using the following: for /F "tokens=1-4...

Why is this?

Thanks,

Steve

Brashquido's picture

Thanks for picking that up.

Thanks for picking that up. So long since I've looked at this script I can't remember the in's and out of it. Have to find some time to go through and update it.
----------------
Dominic Ryan
4 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster