Quantcast
Channel: Dreaming in CRM & Power Platform
Viewing all articles
Browse latest Browse all 113

Backing up plugin/workflow assemblies

$
0
0

One of the ways to quickly backup the plugin/assemblies that are stored in the MSCRM database is to use the Assembly Recovery Tool that comes with XrmToolBox. Recently, I had a situation where I couldn’t back up the assembly this way, as one of the assembly was huge and the OrganizationService was experiencing some latency issues, resulting in a slow performance of the Assembly Recovery Tool.

I followed the method below to quickly backup the assemblies straight from the database.

  1. Install CShell. I prefer this over Linqpad for quickly running C# snippets because you get intellisense for free and it also has a REPL window.
  2. Run the query which is below in SQL Server Management Studio, against the MSCRM database
    SELECT [Name],[Content] FROM dbo.PluginAssemblyBase WHERE IsHidden=0
    
  3. Right click on the result and choose “Save Result As” from the context menu and specify the file name and the location
    SSMSResults
  4. Run the code below in the CShell scratchpad
    var pluginCsv = System.IO.File.ReadAllLines(@"[FULL PATH OF THE SAVED CSV]");
    foreach(var l in pluginCsv)
    {
    	var content = l.Split(',');
    	var assembly = Convert.FromBase64String(content[1]);
    	System.IO.File.WriteAllBytes(string.Concat(@"[OUTPUT PATH FOR THE ASSEMBLY]",content[0],".dll"),assembly);
    }
    

All the assemblies should now be saved to the specified folder. You can use this technique to restore assemblies from database backups of the MSCRM database.



Viewing all articles
Browse latest Browse all 113

Trending Articles