다음을 통해 공유


Scheduling IIS 6.0 Backups

Applies To: Windows Server 2003, Windows Server 2003 with SP1

Using available tools, you can create a simple script to back up your IIS content and configuration as often as is required in your environment. After you create this script, you can type one additional command to schedule the backup to occur regularly.

Backing Up IIS Content

You can include the xcopy command in a simple script for copying IIS and backing up content. Xcopy offers useful parameters for copying permissions, auditing settings, and copying hidden files.

Important

You must be a member of the Administrators group on the local computer to run scripts and executables. As a security best practice, log on to your computer by using an account that is not in the Administrators group, and then use the runas command to run your script or executable as an administrator. At a command prompt, type runas /profile /User:MyMachine</STRONG>Administrator cmd to open a command window with administrator rights and then type cscript.exe ScriptName (include the script's full path and any parameters).

To back up content with xcopy, use the following command-line syntax:

xcopy Source Destination [/o] [/x] [/e] [/h] [/y] [c]

Table 9.11 lists relevant xcopy parameters.

Table 9.11 Xcopy Parameters

Parameter Description

Source

Specifies the name of the source server.

Destination

Specifies the name of the destination server.

o

Copies ACLs.

x

Copies auditing settings (used with /o).

e

Copies the empty directories.

h

Copies the hidden directories.

y

Overwrites without prompting.

c

Continues to copy even if errors occur.

Backing Up IIS Configuration

To back up the metabase, you can run the Iisback.vbs command-line script with the /backup parameter, which places a backup file in systemroot\System32\Inetsrv\Metaback. After you run Iisback.vbs, you should copy the backup file to your main backup location. These examples use the backup location \\Mybackupserver\Share$.

If you want to create a batch file, you can set the name with dynamic variables, such as %date%, and static, user-defined variables, such as %server%.

Next, copy the backup files that are created in the systemroot\System32\Inetsrv\Metaback folder. The files that are created are named Name.MD*#* and Name.SC*#*, where Name is the name you specify and # is the version number of the backup set, starting with zero (0). If you use the same name for subsequent backups, the version number will be incremented by 1 for each backup set that uses the same name. For more information about backing up the metabase, see Working with the Metabase.

Listing 9.16 is an example of a backup batch file that copies both content and configuration.

Listing 9.16   Backup.bat: Sample Backup Batch File

set server=myserver
set name=%date%-%server%
iisback /backup /b %name% /e %password%
xcopy %windir%\system32\inetsrv\metaback\%name%.* \\mybackupserver\share$\%server%  
xcopy /o /x /e /h /y /c c:\web \\mybackupserver\share$\%server%

This batch file copies the backup files and all of the Web content — one or more Web sites that are subfolders of C:\WEB\ — to the backup location that is a subfolder of the folder that has the same name as the server. The defined variables %server% and %name% allow you to change the server name quickly without having to go through the batch file.

To schedule this backup process as a nightly task at 9 pm, type at 9:00p /every:m,t,w,th,f,s,su c:\backup.bat at the command prompt.

For more information about backing up a computer running Windows Server 2003, see How to Back up Data on the Windows Server System 2003 Web site.