Compartilhar via


How to: Create a Class That Is Included in Configuration-Only Backups and Restorations

Applies to: SharePoint Foundation 2010

If you have a custom component that consists of configuration information that farm administrators should have the option of including in configuration-only backups and restorations, you must represent the component with a class that implements the IBackupRestoreConfiguration interface. This topic explains how to do that.

When to Implement IBackupRestoreConfiguration

Your custom component class should implement this interface, and implement its CanBackupRestoreAsConfiguration property to always return true, if the following conditions are met:

  • The class represents only configuration settings.

  • The settings are scoped to the entire farm or to the Content Publishing web service. For more information about the Content Publishing web service, see Background: Service Entities in Microsoft SharePoint Foundation.

  • The settings do not assume any particular server names or any particular farm topology.

Conversely, your class should not implement this interface if it represents content, such as lists, websites, site collections, web applications, supplemental databases, or collections of non-configuration files; nor should it implement this interface if it contains configuration settings that are relative to (or assume the existence of) such content components. In the latter case, the class should probably be implemented as an IBackupRestore child of a parent IBackupRestore object that represents the content.

As a rule, think of a configuration-only backup as a kind of farm template. After Microsoft SharePoint Foundation is installed on a farm, farm administrators can restore the configuration-only components to create a deployment that is configured to match the source farm. The administrators can then optionally restore all, or selected parts, of the original content, or add new content, or both. Although components that implement IBackupRestoreConfiguration can be part of configuration-and-content restorations, it helps to think about the farm template scenario when you are deciding whether a component should implement IBackupRestoreConfiguration. If it would be appropriate for your component to be part of a farm template, even if none of content from the source farm was restored to a new target farm, your class should implement IBackupRestoreConfiguration.

To implement IBackupRestoreConfiguration

  1. IBackupRestoreConfiguration inherits IBackupRestore, so begin by reviewing the introductory part of How to: Create a Content Class That Can Be Backed Up and Restored, and then follow the procedure "To Implement the Members of IBackupRestore" in that topic. However, one exception to that procedure is that the class declaration should indicate implementation of IBackupRestoreConfiguration instead of IBackupRestore. The following is an example:

    [GUID("9573FAD9-ED89-45E8-BD8B-6A5034E03895")]
    public class MyClass : SPPersistedObject, IBackupRestoreConfiguration
    
  2. Implement the CanBackupRestoreAsConfiguration property so that it always returns true, as shown in this example.

    public bool CanBackupRestoreAsConfiguration
    {
        get
        {
            return true;
        }
    }
    
  3. Return to the topic How to: Create a Content Class That Can Be Backed Up and Restored, and continue with the procedure "Add other Members to Your Class As Needed."

See Also

Tasks

How to: Create a Content Class That Can Be Backed Up and Restored

Reference

IBackupRestoreConfiguration