Condividi tramite


IBackupRestore Interface

Enables the content that a class represents to be backed up and restored.

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

Syntax

'Declaration
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public Interface IBackupRestore
'Usage
Dim instance As IBackupRestore
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public interface IBackupRestore

Remarks

By implementing this interface an object representing some content in a SharePoint Foundation deployment becomes something that can be backed up and restored.

Your code does not call the members of IBackupRestore directly. After you have implemented it, your code will construct objects of your custom IBackupRestore classes and add them to the configuration database with the Update() method. Backup and restore applications, such as the SharePoint Foundation Central Administration application, the stsadm.exe console application, and a SharePoint Management Shell cmdlet will make internal calls to the members of your IBackupRestore objects when they are backed up and restored. For more information about how IBackupRestore objects are used, see How to: Create a Content Class That Can Be Backed Up and Restored.

You can create as many types of IBackupRestore classes you want and, if you want, they can be nested as a tree of component classes. But the highest class in any such tree must derive (directly or indirectly) from the SPPersistedObject class and must be a child of SPFarm. If your content class is not a child of any other custom content class, it must derive (directly or indirectly) from SPPersistedObject object and must be a child of SPFarm.

If your class derives from a class that already implements the IBackupRestore interface, and you want to replace an inherited implementation of an IBackupRestore member, your class declaration should explicitly reference IBackupRestore like this:

public class MyClass : SPPersistedObject, IBackupRestore
Public Class [MyClass]
    Inherits SPPersistedObject
    Implements IBackupRestore
End Class

Your override of any IBackupRestore member should explicitly include "IBackupRestore" in the member name and it should not include the public keyword. The following is an example:

String IBackupRestore.Name { ... }
Private Property Name() As String Implements IBackupRestore.Name
... 
End Property

Alternatively, if the implementation of the member in the parent class used the virtual or override keywords, you can use the override keyword in your implementation like this:

public override String Name { ... }
Public Overrides Property Name() As String
... 
End Property

Do not hide the inherited member implementation by redeclaring the member either with or without the new keyword ([new] public String Name { ... }).

If your class derives from SPPersistedObject, then the declaration of fields that you want to persist in the configuration database must be preceded with the [Persisted] attribute. However, you can only mark the following types of fields in this way: primitive types such as strings, integers, and GUIDs; other SPPersistedObject objects or SPAutoserializingObject objects; or collections of any of the above. For example, the class cannot have a FileInfo field marked with the [Persisted] attribute. If the data you would like to persist is not of a persistable class, use a persistable substitute. The sample implementation in the reference topic for the DiskSizeRequired property envisions a class that persists a collection of file names and uses them to create a temporary collection of FileInfo objects at runtime.

If your class can have multiple children of the same type, create a property or field of a collection type or other enumerable type to hold a collection of all children of a given type. This is particularly important if the child type itself implements IBackupRestore, because your implementation of the AddBackupObjects() method should iterate through such children and call the AddBackupObjects() method of each child.

There is basically a one-to-one mapping between objects of type SPBackupRestoreInformation and objects of type IBackupRestore. Each provides a part of the information needed to process a backup or restore of a particular type of content component. Objects of these two types are referenced, respectively, in the Information and IBackupRestore properties of a SPBackupRestoreObject object. The latter class, in addition to acting as a container for the correlated SPBackupRestoreInformation and IBackupRestore objects, provides helper functions for SPBackupRestoreConsoleObject objects.

Note

If your component class represents configuration settings of farm-wide scope or Content Publishing Web Service scope, as distinct from content, it should also implement IBackupRestoreConfiguration which includes IBackupRestore.

See Also

Reference

IBackupRestore Members

Microsoft.SharePoint.Administration.Backup Namespace