Script to securely backup IIS 6.0 Metabase


The following is a script to backup the IIS 6.0 Metabase.  Save it as bkupmeta.bat.

REM delete mapping for H: if it exists
net use h: /del

REM map H: to remote server share
net use h: \\RemoteServer\backup /user:RemoteServer\user password

REM replace YouriisServerName with the name of your IIS web server
SET SERVER=YouriisServerName

REM yymmdd will be the current date. 
REM For example  June 18 2008 will be in the format 080618
SET yymmdd=%date:~12,2%%date:~4,2%%date:~7,2%

REM replace YouriiSserverPassword with the password of an administrative
REM user on the IIS box
SET PASSWORD=YouriiSserverPassword

REM iisback.vbs generates the two metabase backup files and saves them
REM to the %windir%\system32\inetsrv\metaback directory
REM in the format yymmdd.MD0 and yymmdd.SC0
iisback.vbs /backup /b %yymmdd% /e %PASSWORD%

REM copy the metabase backup files to the remote server
REM /y tells xcopy to overwrite any files with the same name
REM on the remote server
Xcopy %windir%\system32\inetsrv\metaback\%yymmdd%.* h:\%SERVER% /y

Now, for the secure part.  We need to encrypt the bkupmeta.bat file so that not just anyone can read it’s contents.  That would be a bad thing, since we have our password saved in the script.

To encrypt the bkupmeta.bat file:

In Windows Explorer right click on the bkupmeta.bat file
Select Properties
Select Advanced
Check the Encrypt Contents to Secure Data check box – OKApply
Select Encrypt the File Only

While you’re at it, double check the bkupmeta.bat‘s ntfs permissions to make sure only the appropriate administrative user has access to the file.  You should also verify the %windir%\system32\inetsrv\metaback\ directory has the appropriate permissions, even though it’s secured by default.

Finally, create a scheduled task that runs bkupmeta.bat whenever you’d like.  Verify the backups are occuring by checking for the MD* and SC* files on the remote server.

This script was modified from one found in Chapter 9 of “IIS 6.0 Administration Scripts, Tips, and Tricks”.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 32 other followers

%d bloggers like this: