共用方式為


SPRestoreSettings class

代表在還原作業的組態設定。設定包含要還原的備份,還原的方法,因此伺服器陣列登入資訊。

Inheritance hierarchy

System.Object
  Microsoft.SharePoint.Administration.SPAutoSerializingObject
    Microsoft.SharePoint.Administration.Backup.SPBackupRestoreSettings
      Microsoft.SharePoint.Administration.Backup.SPRestoreSettings

Namespace:  Microsoft.SharePoint.Administration.Backup
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'宣告
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public NotInheritable Class SPRestoreSettings _
    Inherits SPBackupRestoreSettings
'用途
Dim instance As SPRestoreSettings
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class SPRestoreSettings : SPBackupRestoreSettings

Examples

下列範例會示範如何使用SPRestoreSettings類別的還原作業。完整範例和它的詳細的資訊,請參閱 < How to: Programmatically Restore Content

static void Main(string[] args)
{
    // Create the restore settings.
    SPRestoreSettingssettings = SPBackupRestoreSettings.GetRestoreSettings(@"\\Server\WSSBackups", "Overwrite");

    // Identify the content component to restore.
    Console.Write("Enter name of component to restore (default is whole farm):");
    settings.IndividualItem = Console.ReadLine();
    
    // Set optional operation parameters.
    settings.IsVerbose = true;
    settings.UpdateProgress = 10;
    
    // Create the restore operation and return its ID.
    Guid restore = SPBackupRestoreConsole.CreateBackupRestore(settings);

    SPBackupRestoreObject node = EnsureUniqueValidComponentName(settings, ref restore);

    if (node != null)
    {
        // Set the restore as the active job and run it.
        if (SPBackupRestoreConsole.SetActive(restore) == true)
        {
            if (SPBackupRestoreConsole.Run(restore, node) == false)
            {
                // Report "error" through your UI.
                String error = SPBackupRestoreConsole.Get(restore).FailureMessage;
                Console.WriteLine(error);
            }
        }
        else
        {
            // Report through your UI that another backup
            // or restore operation is underway. 
            Console.WriteLine("Another backup or restore operation is already underway. Try again when it ends.");
        }

        // Clean up the operation.
        SPBackupRestoreConsole.Remove(restore);

        Console.WriteLine("Restore attempt complete. Press Enter to continue.");
        Console.ReadLine();
    }
}// end Main
Shared Sub Main(ByVal args() As String)
    ' Create the restore settings.
    Dim settings As SPRestoreSettings = SPBackupRestoreSettings.GetRestoreSettings("\\Server\WSSBackups", "Overwrite")

    ' Identify the content component to restore.
    Console.Write("Enter name of component to restore (default is whole farm):")
    settings.IndividualItem = Console.ReadLine()

    ' Set optional operation parameters.
    settings.IsVerbose = True
    settings.UpdateProgress = 10

    ' Create the restore operation and return its ID.
    Dim restore As Guid = SPBackupRestoreConsole.CreateBackupRestore(settings)

    Dim node As SPBackupRestoreObject = EnsureUniqueValidComponentName(settings, restore)

    If node IsNot Nothing Then
        ' Set the restore as the active job and run it.
        If SPBackupRestoreConsole.SetActive(restore) = True Then
            If SPBackupRestoreConsole.Run(restore, node) = False Then
                ' Report "error" through your UI.
                Dim [error] As String = SPBackupRestoreConsole.Get(restore).FailureMessage
                Console.WriteLine([error])
            End If
        Else
            ' Report through your UI that another backup
            ' or restore operation is underway. 
            Console.WriteLine("Another backup or restore operation is already underway. Try again when it ends.")
        End If

        ' Clean up the operation.
        SPBackupRestoreConsole.Remove(restore)

        Console.WriteLine("Restore attempt complete. Press Enter to continue.")
        Console.ReadLine()
    End If
End Sub ' end Main

Thread safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

請參閱

參照

SPRestoreSettings members

Microsoft.SharePoint.Administration.Backup namespace