IIS backup - Restore - Delete





-7
Date Submitted Thu. Mar. 2nd, 2006 4:38 AM
Revision 1 of 1
Syntax Master dannyboy
Tags Backup | Delete | IIS | Restore | VBSCRIPT
Comments 0 comments
Create a backup, restore a backup, delete a Backup from IIS

Sub BackupIISMetaBase(IISServer, BackupName)
        ' Backup the IIS Metabase
        On Error Resume Next
        Flags = (MD_BACKUP_SAVE_FIRST Or MD_BACKUP_FORCE_BACKUP)
        Set IIsComputer = GetObject("IIS://" & IISServer)
        If Err.Number <> 0 Then
                WScript.Echo "Failed to create IIS Server object"
                WScript.Quit(2)
        End If
        IIsComputer.Backup BackupName, MD_BACKUP_NEXT_VERSION, Flags4
        If Err.Number <> 0 Then
                WScript.Echo "Failed to create backup"
                WScript.Quit(3)
        End If
        Set IIsComputer = Nothing
End Sub

Sub RestoreIISMetabase(IISServer, Backupname)
        '
Restores an existing IIS Metabase backup
        ' The following line is to make sure that you definetly want to continue with this operation.
        continue = MsgBox("This operation will restore the IIS Metabase. Are you sure you want to do this?", vbYesNo, "IIS Metabase Script")
        If continue = vbNo Then
                WScript.Echo "Metabase restore aborted."
                WScript.Quit(0)
        End If
        Set IIsComputer = GetObject("IIS://" & IISServer)
        IIsComputer.Restore Backupname, MD_BACKUP_HIGHEST_VERSION, 0
        Set IIsComputer = Nothing
End Sub

Sub DeleteIISMetabaseBackup(IISServer, Backupname)
        '
Delete an existing IIS Metabase backup
        Set IIsComputer = GetObject("IIS://" & IISServer)
        IIsComputer.DeleteBackup Backupname, MD_BACKUP_HIGHEST_VERSION
        Set IIsComputer = Nothing
End Sub

 

Comments

There are currently no comments for this snippet.

Voting