Kids, don't try this at home!

Tips & Tricks for C#, ASP.NET and CRM

Dynamics CRM - Backup, Restore & Publish Customizations Programmatically

Here is a simple class you can use to backup, restore and publish dynamics crm customizations programmatically. Please keep in mind that dynamics crm customizations are additive, which means, if you import a set of customizations lets say a new attribute on the account entity and you restore a backup of the old customizations the new attribute on the account entity that was imported will not be deleted.

Usage
CrmCustomizations customizations = new CrmCustomizations(service);

You can backup to an xml file or a zip file by calling the Backup method. Backup method takes care of creating the xml or zip file by looking at the output file extension.
    bool backedup = customizations.Backup(@".\customizations_backup.xml");
    // or to a zip file
    backedup = customizations.Backup(@".\customizations_backup.zip");

To restore a backup call the Restore method. You can pass it a .zip file or a .xml file path.
    bool restored = customizations.Restore(@".\customizations.xml");

Once you have restored you need to publish the customizations, to publish call the Publish method. It will publish all customizations.
    bool published = customizations.Publish();

Download the class file

Enjoy!

Posted: Jul 10 2009, 01:34 PM by gperera | with 3 comment(s)
Filed under:

Comments

JAYAKUMAR JANAKIRAMAN said:

Thanks . This was useful

# August 20, 2009 4:53 PM

Sam Walker said:

Is the "Restore" function the same as the "Import Customizations" function?

# October 5, 2009 1:16 PM

gperera said:

Hi Sam

Yes it is

# October 6, 2009 12:47 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)