SPBackupRestoreSettings class

Stores a pattern of settings for a backup or restore operation.

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

[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public abstract class SPBackupRestoreSettings : SPAutoSerializingObject

This class also provides static methods for creating SPBackupSettings and SPRestoreSettings objects with default settings.

Caution noteCaution

Microsoft does not support deriving new classes from SPBackupRestoreSettings. Use only SPBackupSettings and SPRestoreSettings.

The following example shows how to use the SPBackupRestoreSettings class in a backup application. For the full example and a detailed discussion of it, see How to: Programmatically Back Up Content.

static void Main(string[] args)
    // Identify the location for the backup storage.
    Console.Write("Enter full UNC path to the directory where the backup will be stored:");
    String backupLocation = Console.ReadLine();
    // Create the backup settings.
    SPBackupSettings settings = SPBackupRestoreSettings.GetBackupSettings(backupLocation, "Full");

    // Identify the content component to backup.
    Console.Write("Enter name of component to backup (default is whole farm):");
    settings.IndividualItem = Console.ReadLine();
    // Set optional operation parameters.
    settings.IsVerbose = true;
    settings.UpdateProgress = 10;
    settings.BackupThreads = 10;

    // Create the backup operation and return its ID.
    Guid backup = SPBackupRestoreConsole.CreateBackupRestore(settings);

    // Ensure that user has identified a valid and unique component.
    SPBackupRestoreObject node = EnsureUniqueValidComponentName(settings, ref backup);

    // Ensure that there is enough space.
    Boolean targetHasEnoughSpace = false;
    if (node != null)
        targetHasEnoughSpace = EnsureEnoughDiskSpace(backupLocation, backup, node);

    // If there is enough space, attempt to run the backup.
    if (targetHasEnoughSpace)
        // Set the backup as the active job and run it.
        if (SPBackupRestoreConsole.SetActive(backup) == true)
            if (SPBackupRestoreConsole.Run(backup, node) == false)
                // Report "error" through your UI.
                String error = SPBackupRestoreConsole.Get(backup).FailureMessage;
            // 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.

        Console.WriteLine("Backup attempt complete. Press Enter to continue.");
}// end Main

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