다음을 통해 공유


SPBackupRestoreLogSeverity enumeration

Specifies the severity of an issue that occurs during a backup or restore operation and is logged with a message.

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

Syntax

'Declaration
Public Enumeration SPBackupRestoreLogSeverity
'Usage
Dim instance As SPBackupRestoreLogSeverity
public enum SPBackupRestoreLogSeverity

Members

Member name Description
Important An informational log entry that is important but is not problem.
None No log entry.
Error A fatal error that prevents the operation from completing.
Warning A problem requiring a warning, but not fatal.
Verbose A less important informational log entry that is not a problem.
WorkItem A log entry that identifies certain post-backup or post-restore work that needs to be done.

Remarks

These values are primarily used as parameters to the Log method.

Examples

The following example shows how to use the enumeration in an implementation of the OnRestore method.

[C#]

public Boolean OnRestore(Object sender, SPRestoreInformation args)
{
    if (args == null)
    {
        throw new ArgumentNullException("args");
    }

    // If the CriticalFiles object was deleted from the farm after it was
    // backed up, restore it to the configuration database.
    CriticalFiles cf = SPFarm.Local.GetChild<CriticalFiles>(this.Name);
    if (cf == null)
    {
        this.Update();
        args.Log(SPBackupRestoreLogSeverity.Verbose, this.Name + " added back to configuration database.");
    }

    Boolean successSignal = true;

    // TODO: The following loop restores files to the local server. If there are 
    //       multiple front end servers, your code must iterate through all of 
    //       SPFarm.Local.Servers and restore the same files to every server whose
    //       Role property is SPServerRole.WebFrontEnd

    foreach (String path in FrontEndFilePaths)
    {
        FileInfo backupCopy = new FileInfo(path);
        FileInfo file = new FileInfo(args.Location + @"\" + backupCopy.Name);
        try
        {
            file.CopyTo(path, true);
            args.Log(SPBackupRestoreLogSeverity.Verbose, "Restored " + file.Name);
        }
        catch (Exception e)
        {
            args.Log(SPBackupRestoreLogSeverity.Verbose, file.Name + " not restored: " + e.Message);
            successSignal = false;
        }
    }
    
    args.CurrentProgress = 50;
    return successSignal;
}

See also

Reference

Microsoft.SharePoint.Administration.Backup namespace