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
REM yymmdd will be the current date.
REM For example June 18 2008 will be in the format 080618
REM replace YouriiSserverPassword with the password of an administrative
REM user on the IIS box
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
Check the Encrypt Contents to Secure Data check box – OK – Apply
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”.