Using SPE Sitecore Content Migration script for content sync between Sitecore instances

Jack Spektor
3 min readSep 18, 2022

Hello,

Today I’d like to cover on SPE Content Migrator script.

Recently I was tasked with implementing automated content sync between Sitecore instances.

And as part of investigation I’ve found this beautiful repo with migration script made by Michael West

Here are a few benefits of the script:

  • The script is directly querying data from the database which makes it extremely fast comparing with other options of content migrations
  • The script is smart enough to spot differences between content items, which decreases the number of items that needs to be migrated. It allows to make incremental content transfer, which extremely useful when you are doing regural content transfer between environments
  • The scripts uses Remoting feature which means you can configure and run it from your CI/CD server
  • And it has very extensive logging so you can track the progress of the script from the server as well.
  • And finally! It’s open-source and free to use, unlike some of the commercial tools for content transfer between Sitecore instances (cough… Razl… cough…)

As part of working with the script I’ve made a few changes which I believe you’d find handy:

1: Ignoring certain fields and items from the migration

As you know with every migration there are certain environment-specific items and fields which you don’t want to copy across.

It could be GTM code, settings, or sensitive client content, etc.

Unfortunately original script didn’t had such option, so as part of the job I’ve added two additional arguments to the script — ignoreFieldsIds and ignoreItemsIds.

2. Using Sitecore connector DLL from artifacts

In the original Powershell script the logic is using DLL that would connect to Sitecore and serialize/deserialize items and return them back to Powershell.

As my intention is to add new functionality to serialization logic (such as ignoring fields/items) I had to change that DLL code.

Originally the DLL is loaded by parsing Base64 formatted string.

It looks like this:

Sometimes such option might be handy if you want to setup a migration on CI/CD server without access to artifacts.

Since I’ve made changes to that connector code I had to update base64 symbols.

It could be done with handy Powershell script provided in original repo — Convert-DllToBase64.ps1

However since my CI/CD setup already has compiled artifacts available I’ve thought — why not load the connector logic from them?

Which means now I can do following on my CI/CD during content migration run:

Script usage example for ignored items and fields:

And here is usage example.

As you can see its very similar to original script, except to an option to ignore fields and items.

You can find the original script repository by Michael here:

And here is my forked repository with an option to ignore itemIds and fieldIds.

Hopefully this would make your content syncs easier.

Have a great day!

--

--

Jack Spektor

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