2
votes

I want to transfer items from master database to a similar database (lets say copy of the master database), which is the offline backup of the master database. This update will happen daily.

I have configured the marster_archive database and tried the Sitecore transfer items functionality. It copies selected items from master db to master_archive db.

I want to do this programmatically, how can I do this? (Sitecore 6.6)

1

1 Answers

4
votes

Here is the simplified version of the code which is used by the Transfer command:

public void Transfer()
{
    Item sourceItem = ...;
    Item destinationItem = ...;
    using (new ProxyDisabler())
    {
        string outerXml = sourceItem.GetOuterXml(includeSubitems);
        try
        {
            destinationItem.Paste(outerXml, false, PasteMode.Overwrite);
            Log.Audit((object) this, "Transfer from database: {0}, to:{1}",
                        AuditFormatter.FormatItem(sourceItem),
                        AuditFormatter.FormatItem(destinationItem));
        }
        catch (TemplateNotFoundException ex)
        {
            // handle exception - first transfer templates, than items
        }
    }
}