SPBackupRestoreObject.CanBackup property

Gets or sets a value that indicates whether the component represented by the IBackupRestore property has been selected for backup.

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

public bool CanBackup { get; set; }

Property value

Type: System.Boolean
true if the component should be backed up; otherwise, false.

This property is not an indicator of whether the component is of a type that can be backed up. Instead, it is an indicator of whether the IBackupRestore property is a null reference (Nothing in Visual Basic). If it is a null reference (Nothing in Visual Basic), then the component has not been selected for backup.

The following sample shows the CanBackup property used in an implementation of the Object method.

public String Object(SPBackupRestoreObject obj, int depth)
{
    StringBuilder build = new StringBuilder();

    if (obj.CanBackup == false || obj.CanRestore == false)
    {
        build.Append("*");
    }
    
    if ((obj.Information.IsBackup &&
         !obj.IBackupRestore.CanSelectForBackup) 
        ||
        (!obj.Information.IsBackup &&
         !obj.IBackupRestore.CanSelectForRestore))
    {
        build.Append("[");
    }

    build.Append(obj.Name);

    if ((obj.Information.IsBackup &&
         !obj.IBackupRestore.CanSelectForBackup)
        ||
        (!obj.Information.IsBackup &&
         !obj.IBackupRestore.CanSelectForRestore))
    {
        build.Append("]");
    }

    build.Append("+*+*+");

    return build.ToString();
}
Show: