Migration of Media Content Items? Use my Module to do it fast and easily.

Do you have to migrate 3 GB of Media Content from an old Sitecore XP to a new one and it looks like a nightmare? Not anymore. With the right tools, we can optimize and improve our work!

Using the power of the Sitecore PowerShell Extension I’ve developed a new module to do this job using another perspective. It’s called the [Media Package Generator]. The module divides the Media Content into smaller packages, for example, splitting 3 GB of media content into 30 packages containing 100 MB each.

The benefits of the Module are:

  • You can choose the size of the package, meaning you can have 5, 10, 30, 50, or more packages. There’s a parameter to change it, so it’s up to you.
  • Dividing a large amount of data into small packages prevents Sitecore or IIS from stopping working, which can happen when you are packing items and lose all your work.
  • After all the packages are done, you can zip them into just one file and share it with everyone.
  • After the package generation, there’s an option to install the Packages (which you probably will use on another computer/server), making it easy to install all the packages at once.
  • You can see the progress of the whole operation.
  • You can do an async operation. While some packages are processing, you can send the already-done packages;
  • You can adapt the module to your own specific requirement. If you need to change something, you are able to, it’s made using SPE!

After the module is installed, it’s placed at Development Tools > Media Package Generator.

Here’s how it works:

To create the packages, the process is almost all automatic. You just need to set up a few parameters like the Path node you want to migrate, the Package Name Prefix, the Approximated Size of each package, the Author, the Installation mode, etc.

The module will divide all the content into many packages. Every time the package target the limit set up, it opens the option to download it.

To install the packages, it’s easy:

You have to set up the Package name and the location where it’s is placed.

Prerequisites:

  • Sitecore XP 9.3 or higher (not tested in lower versions)
  • Sitecore PowerShell Extesion 6.4 (not tested in lower versions)
  • Only for Media items

How to install:

The installation is straightforward.

And install it as a regular package in the Sitecore.

If you don’t want to install, just get the script at https://github.com/alvaropmontenegro/sitecore-media-package-generator and use it in the PowerShell ISE

If you encounter any bugs or have suggestions for improvement, please don’t hesitate to get in touch!

That’s all for now!

5 responses

  1. Nagaraju Avatar
    Nagaraju

    Is it possible do the same thing for content items? Please suggest. Size property is not available for normal content items. It is only working for media items.

    1. At this current version, the answer is no, it’s not possible because as you realized the Content Items don’t have the Size property, so the approach to do it for Content Items is a little bit different. I have started working on a solution for the Content Items but I had to stop due to other priorities, so this isn’t finished.
      However, if you need it for now, I’d suggest the following solution:
      1) Copy the Powershell Script code from my Git repository;
      2) Then modify the script and insert something like that:


      $contentItemPath = "/sitecore/content/Qlik/home"

      # Get the Content Item
      $contentItem = Get-Item -Path $contentItemPath

      # Calculate the size of the Content Item
      $contentItemSize = 0

      # Iterate through the fields of the Content Item
      foreach ($field in $contentItem.Fields) {
      $fieldSize = $field.Value.Length
      $contentItemSize += $fieldSize
      }

      # Display the size of the Content Item
      Write-Output "Content Item Size: $($contentItemSize) bytes"

      It should calculate the size of the Content item, but I’m not sure if this is an accurate method because I didn’t have time to test it.

      Let me know if it worked for you, so we can update this module and include your need.

  2. Nagaraju Avatar
    Nagaraju

    I have tried this. It is not calculating the size accurately.

    1. Hi Nagaraju.
      Actually, it’s a big challenge calculating accurately a Content Item size, there’s no simple method or property to access it. I tried many approaches here, but nothing gave me an accurate result. When you create a package it creates a zip file with your items and other stuff (metadata, properties, installer), so even if you’re able to measure the items you cannot measure those extra files.

      So here I have more 2 suggestions:
      1) if you’re looking for something accurate I suggest you serialize all items, then measure the file size, and add it to a zip file (not a package). So on another computer, unzip it and import the serialized items. You can do all those things using SPE.
      2) if the package size doesn’t matter so much, instead of using the Size as a measure, you can count the number of items per package. For example, create 30 packages with 100 items each. Then you have packaged 3000 items.

  3. Nagaraju Avatar
    Nagaraju

    I was already using 2nd approach. Wanted to try if it is possible to get the accurate size. Thanks for the script and your suggestions.

Leave a Reply

Your email address will not be published. Required fields are marked *