SPBackupRestoreSettings.IndividualItem 属性
获取或设置内容的备份或还原的组件。
命名空间: Microsoft.SharePoint.Administration.Backup
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public Property IndividualItem As String
Get
Set
用法
Dim instance As SPBackupRestoreSettings
Dim value As String
value = instance.IndividualItem
instance.IndividualItem = value
public string IndividualItem { get; set; }
属性值
类型:System.String
String 表示服务器场或备份或还原的服务器场的内容的组件的名称。
备注
例如,一个 Web 应用程序可能会被命名为"SharePoint-80";内容数据库可能会被命名为"WSS_Content_1234567890a2b4c6d8e0f2a4b6c8d0e2"。整个服务器场中SharePoint Foundation称为"服务器场"。
此属性用于标识,在spbackup.log或sprestore.log文件中,顶级组件的备份或还原的组件树中。它负责调用代码,以确保日志通过IndividualItem与**FindItems()**方法的第二个参数是准确。(请参见下面的代码示例)。
假如有只有一个可能的匹配项,将工作部分的名称。例如,"WSS_Content"将足以确定假设只有一个名称以"WSS_Content"开头的内容数据库。如果两个父组件每个具有子具有完全相同的名称,并且您希望备份 (或还原) 其中之一,您可以通过将父的名称附加到前面的子名称,用反斜杠字符之间 ; 消除歧义例如,"SharePoint-80\WSS_Content"。如果不明确的名称传递给**FindItems()**方法时,它将返回一个带多个成员的集合。在这种情况下调用代码应提示用户进行更具体。(请参见下面的示例代码)。
任何以下类型的组件,您可以设置此属性:
整个服务器场。(但**[IndividualItem]**的还原操作的整个服务器场时,将还原既不该服务器场的配置数据库和管理中心应用程序的内容数据库。
发布 web 服务的任何内容,除 WSS_Administration web 服务,它发布SharePoint Foundation管理中心应用程序的页面。
任何在发布 web 服务,除管理中心 Web 应用程序内容的 Web 应用程序。
任何 Web 应用程序内的内容数据库。但管理中心 Web 应用程序的内容数据库仅可用于备份操作的IndividualItem 。您无法还原管理中心应用程序的内容。备份可能会很有用,这样它可以与进行比较,作为故障排除的步骤,使用 SQL Server 工具的更高版本创建的数据库的时间点记录。
任何共享服务提供程序所包含的增强的功能的产品,如Microsoft Office SharePoint Server 2007,是安装在SharePoint Foundation。
任何自定义的内容组件,实现IBackupRestore。
备注
服务器场的配置数据库备份操作中如果包含IndividualItem是整个服务器场,但它不能是IndividualItem本身。更重要的是,不还原时的场是IndividualItem的还原操作。无法还原配置数据库。备份可能会很有用,这样它可以与进行比较,作为故障排除的步骤,使用 SQL Server 工具的更高版本创建的数据库的时间点记录。
若要查看在您的服务器场,可以备份操作的对象上的组件名称的明细,可以在服务器命令行上运行stsadm -o backup -showtree命令或导航到操作 > 执行备份管理中心应用程序中。
为获得,以编程的方式,您可以备份操作,对象的服务器场中的组件的名称使用FindItems。
示例
下面的示例演示如何在备份应用程序中使用的IndividualItem属性。有关完整的示例和详细的讨论,请参阅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;
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(backup);
Console.WriteLine("Backup attempt complete. Press Enter to continue.");
Console.ReadLine();
}
}// end Main
Shared Sub Main(ByVal args() As String)
' Identify the location for the backup storage.
Console.Write("Enter full UNC path to the directory where the backup will be stored:")
Dim backupLocation As String = Console.ReadLine()
' Create the backup settings.
Dim settings As SPBackupSettings = 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.
Dim backup As Guid = SPBackupRestoreConsole.CreateBackupRestore(settings)
' Ensure that user has identified a valid and unique component.
Dim node As SPBackupRestoreObject = EnsureUniqueValidComponentName(settings, backup)
' Ensure that there is enough space.
Dim targetHasEnoughSpace As Boolean = False
If node IsNot Nothing Then
targetHasEnoughSpace = EnsureEnoughDiskSpace(backupLocation, backup, node)
End If
' If there is enough space, attempt to run the backup.
If targetHasEnoughSpace Then
' Set the backup as the active job and run it.
If SPBackupRestoreConsole.SetActive(backup) = True Then
If SPBackupRestoreConsole.Run(backup, node) = False Then
' Report "error" through your UI.
Dim [error] As String = SPBackupRestoreConsole.Get(backup).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(backup)
Console.WriteLine("Backup attempt complete. Press Enter to continue.")
Console.ReadLine()
End If
End Sub ' end Main