Razl – Keep Your Sitecore Synchronized

Let’s talk about Sitecore synchronization.

Sometimes a new feature needs to be tested with a set of real data. For example: Content Management(CM) data a UAT server.

There are common approaches like restoring DBs, creating packages, serializing items, etc. However, there are tools specifically designed for this task.

Razl 3.0 Scripts

Razl is a tool that is designed to compare and move data between two different Sitecore instances. The Script Mode feature was included starting from version 2.5 (/script switch) and it makes it possible to automate the data-synchronization process.

The main idea is to create a Razl script that will synchronize specific Sitecore sub-trees and allow them to run that automatically on your build server.

The Razl XML script consists of two main sections–a connections declaration and a set of operations. Different operations can be combined in one script. Find the full list here.

Let’s just focus on the “CopyAll” operation.

Below is a simple XML example for synchronizing the sub-tree between CM and UAT using “CopyAll”:

<razl>
  <connection name="CM" readOnly="true" install="false">
    <url>http://cm.base.domain.com/</url>
    <accessGuid>4e877f7b-9f96-4612-9eb4-916f29ef279e</accessGuid>
    <database>master</database>
  </connection>
  <connection name="UAT" readOnly="false" install="false">
    <url>http://uat.base.domain.com</url>
    <accessGuid>f6ac498d-36a1-4846-b0dc-1b4f2b4f30de</accessGuid>
    <database>master</database>
  </connection>
  <operation name="CopyAll" source="CM" target="UAT">
    <parameter name="itemId">6AF71A22-9A9A-4DAF-AD0E-A2B445599164</parameter>
    <parameter name="overwrite">true</parameter>
	<parameter name="lightningMode">true</parameter>
  </operation>
</razl>

Pay attention to the “lightningMode” parameter. It appears in version 3.0 and will significantly reduce execution time.

Custom Parameters Support

You can pass custom parameters from the command line to the Razl script. This allows for the reuse of the XML config. For example, you can keep a list of a subtree’s root items and run the “CopyAll” operation for all of them.

To pass a parameter from the command line, use the /p:param_name switch. To get a value from the script, use $(param_name)

# list all root items for sync here
$rootItems = "6AF71A22-9A9A-4DAF-AD0E-A2B445599164", # /sitecore/content/Global
             "6030F735-14B9-4B6F-A493-EF8B714581FD", # /sitecore/content/MySite1/Home
             "0A718DB5-0AEC-439E-9064-D8B68517C5A2", # /sitecore/content/MySite1/Products
             "992F1187-5E32-4C35-BF95-390E8F4EB994", # /sitecore/content/MySite2/Home
             "EA63C156-D879-4EF3-9382-2B1011EDDD77", # /sitecore/content/MySite2/Products
             "15451229-7534-44EF-815D-D93D6170BFCB" # /sitecore/media library/Images

foreach ($rootItem in $rootItems) {
    Write-Host Root node: $rootItem
    razl /script:.\SyncNodeCM2UAT.xml /p:itemId=$rootItem
}
<razl>
  <connection name="CM" readOnly="true" install="false">
    <url>http://cm.base.domain.com/</url>
    <accessGuid>4e877f7b-9f96-4612-9eb4-916f29ef279e</accessGuid>
    <database>master</database>
  </connection>
  <connection name="UAT" readOnly="false" install="false">
    <url>http://uat.base.domain.com</url>
    <accessGuid>f6ac498d-36a1-4846-b0dc-1b4f2b4f30de</accessGuid>
    <database>master</database>
  </connection>
  <operation name="CopyAll" source="CM" target="UAT">
    <parameter name="itemId">$(itemId)</parameter>
    <parameter name="overwrite">true</parameter>
	<parameter name="lightningMode">true</parameter>
  </operation>
</razl>

 

Razl Performance Tips

I would like to mention that v.3.0 has some performance improvements compared to 2.5. If you’re using an older version, consider upgrading.

3.0 has the LightningMode feature, which affects performance.

Just to compare the two versions, I’ll provide some test results. For each test I’ve used the same set of 300 Sitecore content items. The script runs on a build server. The two Sitecore instances are on two different servers and all in one local network.

perf

For the first run, the target DB is clean, all 300 items should be moved.

For the second run, the target and source DBs are equal. Therefore, the processing time for these 300 items will be anywhere from 1 to 20 minutes, depending on the amount of changed items from the previous synchronization.

I hope this will help you automate the data synchronization process for your Sitecore instances.

This entry was posted in build, PowerShell, Razl, Sitecore and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s