Share via


IIsComputer.RestoreWithPassword (ADSI)

You can use the RestoreWithPassword method of the IIsComputer (ADSI) object to restore the metabase from a backup and require a valid password (but only if one was used when the IIsComputer.BackupWithPassword (ADSI) method was invoked). The restore operation stops all services dependent on the IISAdmin service (including all servers) until the restore has completed; then it restarts all services. Because of this, if you are restoring the metabase by using a script in an ASP page, you must specify a machine name (and the associated password) other than the one on which your script is executing. You cannot use LocalHost as the machine name. You should be careful to plan for this service interruption when restoring the metabase from a backup.

Syntax

IIsComputer.RestoreWithPassword BackupLocation, BackupVersion, BackupFlags, BackupPassword

Parameters
  • BackupLocation
    A string of up to 100 characters that specifies the backup location. If an empty string is specified, the backup is retrieved from the default location.

  • BackupVersion
    Specifies the version number of the backup to be restored from the backup location or can be the following constant.

    MD_BACKUP_HIGHEST_VERSION Restore from the highest existing backup version in the specified backup location.
  • BackupFlags
    Reserved. Must be zero.

  • BackupPassword
    Optional. Unencrypted valid password for targeted computer. This password must be the same as the one used when the BackupWithPassword method was invoked.

Code Example
  <% 
  Dim ComputerObj, ComputerName 
  'Restore metabase on a different computer. 
  ComputerName = "MyOtherComputer"
  'You can use LocalHost if running under Windows Script Host. 
  Set ComputerObj = GetObject("IIS://" & ComputerName) 
  'Restore the highest number version in MyBackups. 
  ComputerObj.RestoreWithPassword "MyBackups", MD_BACKUP_HIGHEST_VERSION, 0, "MyP@ssWOrd" 
%> 

Remarks

You can use the RestoreWithPassword method with LocalHost in scripts running in a command prompt by using Cscript.exe. For more information, see the Windows Script Host material in the Windows documentation.

important Important The metabase backup and restore functionality exists for versioning purposes, not for cross-machine replication. However, you are not necessarily restricted to restoring the computer from which you initiate the process. For more information about restoring from a back up, see Backing Up and Restoring the IIS Metabase.