SPBackupRestoreObject Class
Provides helper functions for backup and restore operations and acts as a container for an SPBackupRestoreInformation object and its correlated IBackupRestore object.
Inheritance Hierarchy
System.Object
Microsoft.SharePoint.Administration.Backup.SPBackupRestoreObject
Namespace: Microsoft.SharePoint.Administration.Backup
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public NotInheritable Class SPBackupRestoreObject
Dim instance As SPBackupRestoreObject
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public sealed class SPBackupRestoreObject
Remarks
Because it has an IBackupRestore property that returns an IBackupRestore object, a SPBackupRestoreObject object can be thought of as representing a content component of a type that can be backed up or restored.
SPBackupRestoreObject objects can be nested. For more information see the Parent and Children properties. Typically, a tree of SPBackupRestoreObject objects will mirror a tree of content components, such as farm, Web service, Web application, and content database. However, the Reparent method enables you to create trees for backup and restore operations that do not exactly mirror any part of your deployment's tree of components.
This class has no public constructor. Get a reference to a SPBackupRestoreObject object with a method that returns objects of this class; for example GetRoot, or use an indexer to get a reference to a particular member of a SPBackupRestoreObjectCollection object.
This class has several constants that are used to extract information from the object in the Information property.
An SPBackupRestoreObject object persists as an <SPBackupObject> element in an spbackup.xml or an sprestore.xml that is saved in a subfolder of the backup location identified in the Location property of the object in the Information property.
Examples
The following shows the SPBackupRestoreObject class being used in a method that will ensure that the component name submitted by a user uniquely identifies a single component to be the top of the tree of components that will be processed by a backup or restore operation. For the full example and a detailed discussion of it, see How to: Programmatically Back Up Content.
private static SPBackupRestoreObject EnsureUniqueValidComponentName(SPBackupRestoreSettings settings, ref Guid operationGUID)
{
SPBackupRestoreObjectCollection list = SPBackupRestoreConsole.FindItems(operationGUID, settings.IndividualItem);
SPBackupRestoreObjectcomponent = null;
if (list.Count <= 0)
{
Console.WriteLine("There is no component with that name. Run again with a new name.");
Console.WriteLine("Press Enter to continue.");
Console.ReadLine();
}
else if (list.Count > 1) // The component name specified is ambiguous. Prompt user to be more specific.
{
Console.WriteLine("More than one component matches the name you entered.");
Console.WriteLine("Run again with one of the following:");
for (int i = 0; i < list.Count; i++)
{
Console.WriteLine("\t{0}", list[i].ToString());
}
Console.WriteLine("Press Enter to continue.");
Console.ReadLine();
}
else
{
component = list[0];
}
return component;
}// end EnsureUniqueValidComponentName
The following is an example of an <SPBackupObject> element in an sprestore.xml file. The component represented by the element is a Windows SharePoint Services Web application named "SharePoint - 80".
<SPBackupObject Name="SharePoint - 80">
<SPBackupRestoreClass>Microsoft.SharePoint.Administration.SPWebApplication, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</SPBackupRestoreClass>
<SPBackupSelectable>True</SPBackupSelectable>
<SPRestoreSelectable>True</SPRestoreSelectable>
<SPName>SharePoint - 80</SPName>
<SPId>10ea4e6f-ae37-4909-b04f-f516c066bc37</SPId>
<SPCanBackup>False</SPCanBackup>
<SPCanRestore>False</SPCanRestore>
<SPCurrentProgress>0</SPCurrentProgress>
<SPLastUpdate>10/08/2007 20:19:47</SPLastUpdate>
<SPCurrentPhase>NotSelected</SPCurrentPhase>
<SPParameters>
<SPParameter Key="SPDescription"><![CDATA[Content and configuration data for this Web application.]]></SPParameter>
<SPParameter Key="SPName"><![CDATA[SharePoint - 80]]></SPParameter>
<SPParameter Key="10ea4e6f-ae37-4909-b04f-f516c066bc37STATE.xml"><![CDATA[00000005.bak]]></SPParameter>
<SPParameter Key="IdentityType"><![CDATA[NetworkService]]></SPParameter>
<SPParameter Key="DisableKerberos"><![CDATA[False]]></SPParameter>
<SPParameter Key="AllowAnonymous"><![CDATA[False]]></SPParameter>
<SPParameter Key="SPServer"><![CDATA[http://server01/]]></SPParameter>
</SPParameters>
</SPBackupObject>
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.