Share via


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

Public Enumeration SPBackupRestoreLogSeverity

Dim instance As SPBackupRestoreLogSeverity
public enum SPBackupRestoreLogSeverity

Members

Member name Description
Error A fatal error that prevents the operation from completing.
Warning A problem requiring a warning, but not fatal.
Verbose An issue that is not a problem.

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