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();
Enjoy!