2

So I need to re-create some content from Sitecore 7.2 to a new Sitecore 8 instance. What we had in mind is to create a script using PowerShell in the new Sitecore 8 instance to fetch the needed data item from the old Sitecore 7.2 instance(via the Item Web Api), and then create new items based on that data. For this, we have to install Powershell Extension in the Sitecore 8 instance. So basically:

Old Instance >>> New Instance (using SPE to get data from old instance)

Is there any other better approach to tackle this ?

It's worth mentioning we may have to insert renderings dynamically when creating the items, and we need flexibility (for this matter, the Sitecore 8 ItemService API doesn't work for us, since it doesn't allow us to dynamically add renderings and such to an item).

3 Answers 3

3

Here are a few options you can take:

1- Serialize the Sitecore items you want to move and deserialize on the new instance.

2- Write an SPE script which is what you suggested you are going to do right

3- Use the Razl tool from Hedgehog to compare and move items from one database to the other. You can read more about this here.

Hope this is helpful

2
  • Thanks so much, correct me if Im wrong, but since we need flexibility in terms of creating an item (adding renderings to the item, and such) and template may contain different fields from each other, I think the second option is more viable. Jan 2, 2018 at 19:41
  • 1
    yes probably as with the migration done through scripting you have more control over what goes where and with which renderings. I guess this comes down to whether you want to keep your existing structure from your source instance to your target. if you want then option 1 and 3 probably are the best for you. If you have custom scenarios depending on conditions 'a' or 'b' you need to do 'c' then SPE is probably your best bet
    – Diego
    Jan 2, 2018 at 19:45
5

You will need some sort of script to manipulate and transform the data from one form to another. You could do this using some C# code and utilising the Sitecore API but my personal preference would be to use Sitecore PowerShell Extensions as you are planning to do.

Data Migration

In order to "migrate" the data from the old 7.2 instance to the new 8.2 instance you can use any of the options suggested by @Diego in his answer or use the Express Migration Tool (and select to migrate Items only).

This will then allow you to more easily work with the data in your SPE scripts since it is then a "local" instance and you do not need to mess around with the Item Web API as well as having the advantage of providing a richer API in my opinion. You can treat the items as data only and write transform scripts to create new items based off the old data in whatever structure you need, then finally delete the items once you have finished.

Secondary Master Database

If you really do not want to bring the old data into your new instance and want to treat it as a separate data repository then I would consider attaching the old master database from the 7.2 instance to your new 8.2 instance and then working with it directly from your SPE scripts.

  1. Attach the 7.2 instance database to your SQL server and add a connection string entry:
<add name="legacymaster" connectionString="Initial Catalog=sitecore72_master;..." />
  1. Copy the sitecore/databases/database[@id='master'] node and rename the id attribute to match the connString:
<?xml version="1.0"?>
<sitecore>
  <databases>
    <database id="legacymaster" singleInstance="true" type="Sitecore.Data.DefaultDatabase, Sitecore.Kernel">
      <param desc="name">$(id)</param>
      ...
    </database>
</sitecore>
  1. You can now reference the old databse form your 7.2 instance directly in your PowerShell scripts to access the data and then copy/transform/create items in the master database of your new 8.2 instance:
# Get the original item from the 7.2 instance
$olditem = Get-Item -Path "legacymaster:\content\home\oldpath"

# Create a new item in the new 8.2 instance
$newitem = New-Item -Path "master:\content\home\sample item\Sample Item 3" -ItemType "Sample/Sample Item"

# Edit the item to set correct values of fields etc.
$newitem.Editing.BeginEdit()
$newitem["New Field"] = $olditem.SomeField
$newitem["Other Field"] = $olditem.SomeOtherField
#add any other changes you need
$newitem.Editing.EndEdit()

Once your migration and transformation is complete you can delete the old database, connection string and config patch. This should providing an easier mechanism for you to write your scripts rather than using the Item Web API in my opinion.

2
  • The thing is, I don't think we can meddle too much with the instances in regards of installing things. Anyway, this answer is very informative and insightful, thanks so much! Jan 2, 2018 at 20:33
  • @JoelAlvarezMyrrie If you don't want to attach a backup then you can point the ConnString to your existing 7.2 database and then it's just adding the config changes. Personally, I prefer not to work against a production database if it can be avoided.
    – jammykam
    Jan 4, 2018 at 5:52
0

Have you looked at the Sitecore Express Migration tool? It can do the raw data migration piece fairly well: https://dev.sitecore.net/Downloads/Express_Migration_Tool.aspx

From there, you could write an SPE script that runs on the new 8.x instance and updates the renderings at that point, once all data is migrated over. It might make it easier than having to work with the APIs on the fly, unless you have a need to specifically do things on the fly.

1
  • From the old site, we aren't allowed to install anything, so Sitecore Express Migration tool is ruled out! Also, the instances site structures are different: templates might have different fields, etc. Jan 2, 2018 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.