Export (0) Print
Expand All

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)

public enum SPBackupRestoreLogSeverity

Member nameDescription
ImportantAn informational log entry that is important but is not problem.
NoneNo log entry.
ErrorA fatal error that prevents the operation from completing.
WarningA problem requiring a warning, but not fatal.
VerboseA less important informational log entry that is not a problem.
WorkItemA log entry that identifies certain post-backup or post-restore work that needs to be done.

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

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;
}
Show:
© 2014 Microsoft