Automating transferring content between Sitecore environments using Unicorn serialization

Jack Spektor
3 min readMay 24, 2020

As it often happens our Sitecore solutions are deployed between multiple environments — Local, DEV, QA, UAT and PROD of course.

And as content on PROD updates its a common task to bring the content back from production environment back to testing.

Often these tasks are time-consuming — for this article my goal would be to look on how we could automate them.

The requirements to the solution would be to:

  • be configurable — we should be able to specify which parts of content we’d like to move across
  • be environment-agnostic — we’d like to exclude content that could be specific to environment such as GTM ids, environment site bindings, etc.
  • be reliable — we’d like to track the progress of the serialization/de-serialization

There are many common approaches to that each with its own cons and pros:

My first attempt with automation was to use Powershell Extensions and serialize the Sitecore content tree like is done in this blogpost:

However I faced multiple issues with this approach:

  • Some items Sitecore completely refused to de-serialize due to some characters in serialized files. The same problem appeared during Sitecore package installation as well.
  • The serialization was taking too much time to serialize

This lead me to look into direction of Unicorn serialization and the decision to use it as a way to transfer content between environments (we use TDS to track items in source control)

Another great benefit of Unicorn is that its using Rainbow serialization and Dilithium serialization mode that have much better performance to standard Sitecore serialization.

So lets look into Unicorn and transferring content

First step was to install and setup Unicorn configuration on the project

I wouldn’t cover the installation of Unicorn — there are some great guides available already like this one —

Here I’ll describe my Unicorn configuration in Unicorn.Configs.Default.config and how it could help to improve content transfer between environments.

Here I have 2 content trees configured for serialization through Unicorn. Transparent synchronization (enableTransperentSync) is turned off as we don’t need Sitecore to use file system serialized items as data provider.

Also here we can configure to filter fields and content trees that would be excluded during the serialization (see fieldFilter and exclude tags). Its extremely helpful to make sure that we only copy those content that is not environment specific.

To check that everything is configured well you can run the Unicorn serialization from the Unicorn admin page (/unicorn.aspx).

Now before moving to using Powershell for running Unicorn serialization we must ensure that Unicorn.Dilithium.config and Unicorn.Powershell.config configs are enabled in the config folder.

Let’s do some serialization now!

For that we’ll create a small Powershell script that we’ll use (I hope you have Powershell Extensions Module installed!)

This script would run Unicorn Rainbow serialization for specified configurations, then would package the serialized items and put the archive to the data folder.

To make sure nothing interrupts the process of serialization/deserialization we’d also capture the operations progress to log file, so we’d be able to check later if everything went well and data is consistent.

Now all its required is to copy it to another environment dataFolder and run the same script again.




Jack Spektor

Sitecore MVP 2018–2020, Sitecore Developer in AKQA, traveler and lover of life.