SPBackupRestoreObject class
提供的備份與還原作業的 helper 函數和動作顯示成SPBackupRestoreInformation物件以及其相關的IBackupRestore物件的容器。
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
備註
因為已定義一個IBackupRestore屬性會傳回IBackupRestore物件,可以的思考SPBackupRestoreObject物件,做為代表內容類型,可以備份或還原的元件。
可以巢狀SPBackupRestoreObject物件。如需詳細資訊,請參閱Parent和Children屬性。一般而言, SPBackupRestoreObject物件的樹狀目錄將鏡像樹狀目錄中的內容的元件,例如伺服器陣列、 Web 服務、 Web 應用程式及內容資料庫。不過, Reparent方法可讓您建立樹狀結構的備份及還原不完全鏡像您的部署的元件的樹狀目錄的任何部分的作業。
此類別有無 public 建構函式。使用一種方法可傳回此類別中 ; 物件取得SPBackupRestoreObject物件的參照例如GetRoot或使用索引器,以取得SPBackupRestoreObjectCollection物件的特定成員的參照。
此類別有數個常數,用來從Information屬性中的物件擷取的資訊。
SPBackupRestoreObject物件依然存在spbackup.xml或Information屬性中物件的Location屬性中所識別的備份位置的子資料夾中儲存sprestore.xml<SPBackupObject>元素。
Examples
以下顯示SPBackupRestoreObject類別,確保元件名稱送出使用者的唯一方法中所識別為元件會處理的備份或還原作業的樹狀目錄的頂端的單一元件。完整範例和它的詳細的資訊,請參閱 < How to: Programmatically Back Up Content。
private static SPBackupRestoreObject EnsureUniqueValidComponentName(SPBackupRestoreSettings settings, ref Guid operationGUID)
{
SPBackupRestoreObjectCollection list = SPBackupRestoreConsole.FindItems(operationGUID, settings.IndividualItem);
SPBackupRestoreObject component = 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
Private Shared Function EnsureUniqueValidComponentName(ByVal settings As SPBackupRestoreSettings, ByRef operationGUID As Guid) As SPBackupRestoreObject
Dim list As SPBackupRestoreObjectCollection = SPBackupRestoreConsole.FindItems(operationGUID, settings.IndividualItem)
Dim component As SPBackupRestoreObject = Nothing
If list.Count <= 0 Then
Console.WriteLine("There is no component with that name. Run again with a new name.")
Console.WriteLine("Press Enter to continue.")
Console.ReadLine()
ElseIf list.Count > 1 Then ' 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 i As Integer = 0 To list.Count - 1
Console.WriteLine(vbTab & "{0}", list(i).ToString())
Next i
Console.WriteLine("Press Enter to continue.")
Console.ReadLine()
Else
component = list(0)
End If
Return component
End Function ' end EnsureUniqueValidComponentName
以下是<SPBackupObject>元素sprestore.xml檔案中的範例。表示項目元件是SharePoint Foundation名為"SharePoint – 80"的 Web 應用程式。
<SPBackupObject Name="SharePoint - 80">
<SPBackupRestoreClass>Microsoft.SharePoint.Administration.SPWebApplication, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</SPBackupRestoreClass>
<SPBackupSelectable>True</SPBackupSelectable>
<SPRestoreSelectable>True</SPRestoreSelectable>
<SPName>SharePoint - 80</SPName>
<SPId>6abb0dec-eeab-42d2-8996-af63b8a3ef60</SPId>
<SPCanBackup>True</SPCanBackup>
<SPCanRestore>True</SPCanRestore>
<SPCurrentProgress>100</SPCurrentProgress>
<SPLastUpdate>04/27/2009 12:34:56</SPLastUpdate>
<SPCurrentPhase>Done</SPCurrentPhase>
<SPParameters>
<SPParameter Key="6abb0dec-eeab-42d2-8996-af63b8a3ef60STATE.xml"><![CDATA[00000003.bak]]></SPParameter>
<SPParameter Key="ApplicationPoolId"><![CDATA[SharePoint Content Application Pool]]></SPParameter>
<SPParameter Key="Features.xml"><![CDATA[0000001B.bak]]></SPParameter>
<SPParameter Key="IdentityType"><![CDATA[SpecificUser]]></SPParameter>
<SPParameter Key="OutboundMailServer"><![CDATA[smtp.example.com]]></SPParameter>
<SPParameter Key="SPDescription"><![CDATA[Content and configuration data for this Web application.]]></SPParameter>
<SPParameter Key="SPName" InputDescription="New web application name:"><![CDATA[SharePoint - 80]]></SPParameter>
<SPParameter Key="SPServer" InputDescription="New web application URL:" ForceLtr="true"><![CDATA[http://sharepoint.example.com/]]></SPParameter>
<SPParameter Key="SPUserName"><![CDATA[DOMAIN\username]]></SPParameter>
<SPParameter Key="WebApplicationId"><![CDATA[67bf6cdb-8fc9-457f-9764-6a8bbf07769e]]></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.