SPRestoreSettings Class

Represents the configuration settings for a restore operation. The settings include the method of restoration, the backup to be restored, and farm logon information.

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

The following example shows how to use the SPRestoreSettings class in a restore operation. For the full example and a detailed discussion of it, see 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

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.

See Also

Reference

SPRestoreSettings Members

Microsoft.SharePoint.Administration.Backup Namespace