Why is a content snapshot created on install?

Created on 11 July 2025, 3 months ago

Problem/Motivation

This module implements an installation hook which creates a content snapshot:
https://git.drupalcode.org/project/content_sync/-/blob/4.0.0-rc2/content_sync.install?ref_type=tags#L10

When installing this module on larger sites, this installation process can take hours. (see Add config to be able to ignore entity types Needs review )

What is the reasoning behind creating a content snapshot during installation?

I was not able to discern the reason from the git history: https://git.drupalcode.org/project/content_sync/-/commit/58370908

Steps to reproduce

  1. Have a site with a large number of content entities.
  2. Install this module.

Proposed resolution

Document the reasoning behind creating a content snapshot during installation and depending on the answer, remove or change that functionality. Snapshots could always be created manually.

Add config to be able to ignore entity types Needs review might be a good approach to change that functionality. And I think it makes sense even if the install hook functionality is removed.

Remaining tasks

  • Answer this issue's question.
  • Discuss proposed resolutions.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

💬 Support request
Status

Active

Version

4.0

Component

Documentation

Created by

🇩🇪Germany tgauges

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @tgauges
  • 🇩🇪Germany tgauges

    Here is a simple patch, just removing the install hook for those who want it.

  • 🇩🇪Germany tgauges

    I think I gained a bit of understanding about the inner workings of this module which might help answer this issue's question: This module tries to always keep a current content snapshot in the database. The export command only seems to refer to this snapshot to decide which entities to export.

    And the filtering logic of the command (--entity-types) therefore only acts on the already created content snapshot.

    Meaning if one implements a filtering of entities during the snapshot creation, the export command filtering can only act on the already filtered content. Some dependencies might be missing.

    Is that understanding correct?

  • 🇨🇦Canada blanca.esqueda

    Hi tgauges!

    This module tries to always keep a current content snapshot in the database.

    This is correct, the module tries to always have a up to date snapshot, as one of the uses of the snapshot is to compare the current content vs the content on the content/sync folder.

    The export command only seems to refer to this snapshot to decide which entities to export.
    And the filtering logic of the command (--entity-types) therefore only acts on the already created content snapshot.

    Yes and no, filter is to limit the entities, but the export functionality checks for the entities directly on the dabase and update the snbapshot if it is out of sync.

    Meaning if one implements a filtering of entities during the snapshot creation, the export command filtering can only act on the already filtered content. Some dependencies might be missing.

    Yes and no, it depends on the options being used.
    If you use "-include-dependencies" it will pull the dependencies even if they are entities not set on the filter options.

    I'll try to expand on the documentation.
    Also, there are a couple of tasks asking to remove the snapshop on install- so the next version won't have it on install but it will have a settings screen to select the entities to use and the option to include or not dependencies as on the drush command.

  • 🇩🇪Germany tgauges

    Hi Blanca, thank you for the answers.

    but the export functionality checks for the entities directly on the database and update the snapshot if it is out of sync.

    I was a bit confused by that answer, because I tried running the command drush content-sync:export --entity-types=node on a development instance where I removed the install hook and got no result on an empty snapshot directory. Then I took a closer look at the code and noticed that with 8f62d80c ( Add drush options `force` or `partial` option on import/export Needs work ) there is an option to make the export command use the entities directly instead of the snapshot. This commit is not yet released.

    so the next version won't have it on install but it will have a settings screen to select the entities to use and the option to include or not dependencies as on the drush command.

    Sounds great, I'm looking forward to it.

Production build 0.71.5 2024