Syncing Plone content between Plone sites: collective.contentsync2

I just wanted to let you know that there is a new tool (implemented as behavior) that allows you to sync content between Plone sites over plone.restapi named collective.contentsync:

It was written by Thomas Massmann @tmassman for a customer of mine. I refactored it into a dedicated package.

There is no official release yet, documentation is stil sparse...I plan to bring collective.contentsync into a better shape until Plone Conference 2020.

We had to solve the following use case:

  • we migrated the customer site dynamore.de to Plone 5.2 in fall this year
  • their swedish branch is running their own Plone portal dynamore.se with a mixture of content from the dynamore.de site and content that is specific to their own site
  • in order to migrate their site properly, we performed a partial export-import migration and then used the sync functionality for moving/updating the common content from the dynamore.de site to the dynamore.se site (not officially launched)

The add-on requires Plone 5.2, Python 3.

8 Likes

Let me add my 2 cents here :wink:

This add-on can be used to push changes from one Plone site to a list of configured other Plone sites (one-way-sync). They should have the same Plone Major versions, but it is not required. Depending on the content which is synced, the installed add-ons should match. The add-on uses plone.restapi to push the content.

You can configure a list of target sites (the Plone sites you want to sync to), with URL, username and password for a user who has at least the Contributor role.

To enable the content sync (push), you need to add a content rule with the content sync action. There is nothing more to configure for that rule, but it needs to be enabled either for the whole site or just a sub tree. So it is up to you when the sync should happen (content added, workflow changed, ...).

The add-on comes with a behavior (an action and a manage screen would work too, but for the customer the behavor was the easier way). There you can add a configuration for all configured targets. The content sync can be enabled and also include all sub items. It also contains an option to exclude an item from the sync process.

With that you have almost unlimited options. For example, a products folder can be synced from example.com to sub1.example.com/products and sub2.example.com/products. Now one item in that products folder should not be synced to sub1, but to sub2. This can be achieved by excluding the item from sync, and then by adding a new sync configuration for sub2 starting at this point.

The add-on allows you to sync content immediately, manually or triggered by a cron job. This can be adjusted in the control panel. To sync via cron job, best is to create an instance script which calls the full sync method and call that with your cron job.

By default, only the object that triggered the content rule will be synced, not the sub content. This is to prevent long running tasks. You can do a full sync to sync all content, or just the items left in the queue (which might have failed for some reason).

There is also an option to exlude fields for updates. So when an item is created, all fields are synced. But on update you can choose which are ignored (e.g. for local customizations on the target site).

One more thing: the sync will only update existing content on the target site if the UID matches. For this to work there is a new restapi service to update the UID after the item was created on the target site. Maybe this (passing the UID) can be included in the restapi service for creating content.

6 Likes

The package has been renamed to collective.contentsync2 (due to a nameclash on PyPI).

The repo is now: https://github.com/collective/collective.contentsync2

The documentation has been updated with screenshots etc. and there is also release on PyPI (images are broken here, requires a dedicated doc release using Sphinx):

Great work! I just want to remark, the screenshots are broken both, on PyPI and Github.

yeah, work in progress...it's stupid when your documentation with images does not work on Github, on PyPI and on ReadTheDocs :pleading_face:

1 Like

Fixed with a proper doc release on RTD

1 Like

Plone Foundation Code of Conduct