del método SPBackupRestoreSettings.GetRestoreSettings
Crea un objeto SPRestoreSettings con origen especificado y método y otros valores establecidos en sus valores predeterminados.
Espacio de nombres: Microsoft.SharePoint.Administration.Backup
Ensamblado: Microsoft.SharePoint (en Microsoft.SharePoint.dll)
Sintaxis
'Declaración
Public Shared Function GetRestoreSettings ( _
directory As String, _
restoreMethod As String _
) As SPRestoreSettings
'Uso
Dim directory As String
Dim restoreMethod As String
Dim returnValue As SPRestoreSettings
returnValue = SPBackupRestoreSettings.GetRestoreSettings(directory, _
restoreMethod)
public static SPRestoreSettings GetRestoreSettings(
string directory,
string restoreMethod
)
Parámetros
directory
Tipo: System.StringEl directorio donde el origen de la operación de restauración; que es la copia de seguridad de los objetos que se va a restaurar, se guarda.
restoreMethod
Tipo: System.StringEl tipo de restauración, "Nuevo" o "Sobrescribir".
Valor devuelto
Tipo: Microsoft.SharePoint.Administration.Backup.SPRestoreSettings
Un objeto SPRestoreSettings con todos los valores establecidos en sus valores predeterminados.
Comentarios
restoreMethod debe ser una representación de String de un valor de SPRestoreMethodType .
Ejemplos
El ejemplo siguiente muestra cómo utilizar el método GetRestoreSettings en una operación de restauración. Para obtener una explicación detallada de la misma y el ejemplo completo, vea How to: Programmatically Restore Content.
static void Main(string[] args)
{
// Create the restore settings.
SPRestoreSettings settings = 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
Shared Sub Main(ByVal args() As String)
' Create the restore settings.
Dim settings As SPRestoreSettings = 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.
Dim restore As Guid = SPBackupRestoreConsole.CreateBackupRestore(settings)
Dim node As SPBackupRestoreObject = EnsureUniqueValidComponentName(settings, restore)
If node IsNot Nothing Then
' Set the restore as the active job and run it.
If SPBackupRestoreConsole.SetActive(restore) = True Then
If SPBackupRestoreConsole.Run(restore, node) = False Then
' Report "error" through your UI.
Dim [error] As String = SPBackupRestoreConsole.Get(restore).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(restore)
Console.WriteLine("Restore attempt complete. Press Enter to continue.")
Console.ReadLine()
End If
End Sub ' end Main
Vea también
Referencia
Miembros SPBackupRestoreSettings
Espacio de nombres Microsoft.SharePoint.Administration.Backup