enonic / cms2xp

Enonic CMS to XP migration tool
0 stars 0 forks source link

Enonic CMS to XP migration tool

This repository contains the code for the CMS to XP migration tool.

The migration works from CMS 4.7 to XP 6.x.

Enonic CMS Enonic XP



Download

Download the latest version: 0.10.12

Releases

CMS2XP version Required XP version Download
0.10.8 6.9.0 Download 0.10.8 distribution
0.10.9 6.9.0 Download 0.10.9 distribution
0.10.10 6.9.0 Download 0.10.10 distribution
0.10.11 6.9.0 Download 0.10.11 distribution
0.10.12 6.9.0 Download 0.10.12 distribution

Change log

See change log for the released versions here

Building

Before trying to build the project, you need to verify that the following software is installed:

Build all code and run all tests including integration tests:

gradle build

A distribution zip, containing all the required files for running the tool, will be generated in build/distributions/cms2xp-0.10.12.zip

Running

There is just one script command to execute the CMS to XP migration tool. The script takes one parameter: the path to a config.xml file.

Note that the tool must be executed from a computer with file access to the CMS blobs and resources directories, normally located in the CMS_HOME directory of the CMS installation. It also needs direct connection access to the database where the CMS data is stored. The CMS itself does not need to be running.

To run the script, extract the distribution zip file to an empty directory and execute the script from the command line:

If the config.xml parameter is omitted, it will print out an example of config XML. See also Configuration below.

Before running this tool, the SQL driver to the CMS database must be copied to the lib directory. This is normally a .jar file specific to a database version, like postgresql-9.3-1104.jdbc4.jar.

Configuration

The configuration is divided in two parts:

Example of config.xml:

<config>
  <!-- Source (CMS) -->
  <source>
    <jdbcDriver>org.h2.Driver</jdbcDriver>
    <jdbcUrl>jdbc:h2:~/cms-home/data/h2/cms</jdbcUrl>
    <jdbcUser>sa</jdbcUser>
    <jdbcPassword>***</jdbcPassword>
    <blobStoreDir>./cms-home/data/blobs</blobStoreDir>
    <resourcesDir>./cms-home/data/resources</resourcesDir>
    <exclude>
      <site>old_site</site>
      <site>42</site>
      <contentPath>/old_content</contentPath>
      <contentPath>/images/not_in_use</contentPath>
      <userStore>legacyUserStore</userStore>
    </exclude>
    <include>
      <!-- specify either exclude or include, but not both at the same time -->
    </include>
  </source>

  <!-- Target (XP) -->
  <target>
    <exportDir>./export</exportDir>
    <userExportDir>./export_user</userExportDir>
    <applicationDir>./application</applicationDir>
    <applicationName>com.enonic.xp.app.myApp</applicationName>
    <applicationRepo>starter-vanilla</applicationRepo>
    <exportApplication>true</exportApplication>
    <exportMenuMixin>true</exportMenuMixin>
    <moveHomeContentToSection>true</moveHomeContentToSection>
    <exportCmsKeyMixin>false</exportCmsKeyMixin>
    <exportCmsMenuKeyMixin>true</exportCmsMenuKeyMixin>
    <exportCmsImageMixin>true</exportCmsImageMixin>
    <exportCmsStatusMixin>true</exportCmsStatusMixin>
    <logFile>cms2xp.log</logFile>
  </target>
</config>

Source parameters

The source parameters include the details necessary for connecting to the CMS database, and the path to the blobs and resources from the CMS.

Parameter Description Example
jdbcDriver JDBC driver class. "org.postgresql.Driver"
jdbcUrl JDBC URL pointing to the CMS database. "jdbc:postgresql://localhost:5432/customer"
jdbcUser Username for the CMS database. "db_user"
jdbcPassword Password for the CMS database. "password123"
blobStoreDir Local file path to the blobs directory of the CMS. "./cms-home/data/blobs"
resourcesDir Local file path to the resources directory of the CMS. "./import/home/data/resources"
resourcesDir Local file path to the resources directory of the CMS. "./import/home/data/resources"
ignoreDrafts Skips content where the main version is a draft. Default is false. "true"
exclude/site Site key or name in the CMS to be excluded from the export. Optional. "old_Site", "33"
exclude/contentPath Content path prefix in the CMS to exclude from the export. If the path corresponds with a category, none of its subcategories will be exported. Optional. "MyContent/old/data"
exclude/userStore User store key or name to exclude from the export. Optional. "my_user_store", "42"
include/site Site key or name in the CMS to be included in the export. Optional. "new_Site", "42"
include/contentPath Content path prefix in the CMS to include in the export. If the path corresponds with a category, all its subcategories will be exported. Optional. "MyContent/new/data"

Target parameters

The target parameters include the desired path where to generate XP export directories. Two different exports will be generated, one with CMS content and the other with user store data.

There are also parameters to specify path and name for generating an XP application. This application will contain content types, mixins, parts and pages, converted from CMS. There are also some optional switches for altering the output.

Parameter Description Example
exportDir Directory path where to generate the XP export for content. "./contentExport"
userExportDir Directory path where to generate the XP export for user stores and principals. "./userExport"
applicationDir Directory path where to generate the XP application. "./myapp"
applicationName Name for the generated XP application. "com.acme.myapp"
applicationRepo Name of an XP starter app to be used as a skeleton for the generated app. Default is "starter-vanilla". "starter-vanilla"
exportApplication If set to "false" the XP application will not be generated. Default is "true". "false"
exportPublishDateMixin Whether or not include the publish mixin in the application and content exported. This option is deprecated. CMS publish fields are now exported to map with XP publish fields.
exportMenuMixin Whether or not convert CMS menu properties ('Menu name', 'Show in menu'), and include the menu mixin in the application. Default is "true" "false"
moveHomeContentToSection Move content that is published on a single section, under the content corresponding to the section in XP. Set to "false" to avoid moving the content. Default is "true" "false"
exportCmsKeyMixin Whether or not include the cmsContent mixin and add the content key (or category key) as a property in every content exported. Also the Home menu-item key where the content is published will be included. Default is "false" "true"
exportCmsMenuKeyMixin Whether or not include the cmsMenu mixin and add the menu item key as a property in every content exported. Default is "false" "true"
exportCmsImageMixin Whether or not include the cmsImage mixin and add the "Related file" field from CMS in every image exported. Default is "true" "false"
exportCmsStatusMixin Whether or not include the cmsStatus mixin and add the "Content Status" field from CMS in every content exported. Default is "true" "false"
logFile Path of file where to write export log info. If not set log info will be sent to standard output.

How to use

The process of migrating CMS data to XP includes some additional actions after running the CMS2XP tool.

These are the suggested steps for migrating CMS data:

  1. Create and fill in a config.xml file according to the details above.

  2. Execute the cms2xp script:

    ./bin/cms2xp config.xml
  3. If all goes well 3 directories will be created with: content data, user store data, and an XP application.

  4. Build and deploy the application:

    <applicationDir>$ gradle clean deploy
  5. Move the content export to XP export directory:

    mv <exportDir> $XP_HOME/data/export/cms_content
  6. Move the user store export to XP export directory:

    mv <userExportDir> $XP_HOME/data/export/cms_users
  7. Import user store export into XP:

    $XP/toolbox/toolbox.sh import -a su:pwd -t system-repo:master:/identity -s cms_users/identity
  8. Import content export into XP:

    $XP/toolbox/toolbox.sh import -a su:pwd -t cms-repo:draft:/content -s cms_content/content
  9. Reprocess the imported content to update the metadata in media content:

    $XP/toolbox/toolbox.sh reprocess -a su:pwd -s draft:/

See XP documentation for more details about the import and reprocess commands.

Notes

There are some remarks and limitations on the exported data:

For questions, feature requests, or reporting issues, please use the Enonic Discuss forum.