Closed (fixed)
Project:
Content Synchronization
Version:
3.0.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Issue tags:
Reporter:
Created:
26 Apr 2017 at 16:37 UTC
Updated:
8 Oct 2021 at 20:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
bircherI am looking forward to tying out this module when paragraphs are supported.
just fyi, look at how we solved having the same code base for drush and drupal console commands in config_split.
It makes it also easier to support drush 8 and drush 9 commands.
It boils down to creating a cli service that has a method that does what you need to do. Then you add the drush and console commands that get the arguments in their own respective way and pass it to your service which does all the work. This also allows you to test the methods more easily which reduces the surface of possible bugs.
See the drush command and the cli service.
Comment #3
blanca.esqueda commentedHi bircher,
We are planning to do another release next week, on Friday August 4th.
Drush commands and support to paragraphs and in theory any custom field would be included on that release.
We have spent some time re-organizing methods and services, but for sure we would take a look to how you solved it in config_split - Thank you for the tip!
I'll update the status of this issue as soon as the next release is done and would appreciate your feedback.
Regards,
Blanca
Comment #4
websiteworkspace commentedOnce this module is more fully fleshed out, it would be great to have drush commands for all of this module's functionality, so that the functionality can be incorporated into shell scripts of drush command sets.
Comment #5
acmoncadab4 commentedHello, here an implementation for Drush 9.
Comment #6
acmoncadab4 commentedAdjusts the import source directory.
Comment #7
dabito commentedComment #8
acmoncadab4 commentedAdds files support.
Comment #9
acmoncadab4 commentedIncludes files folder into the exported compressed archive.
Comment #10
acmoncadab4 commentedAdds entity_types filter.
Comment #11
dabito commentedComment #12
acmoncadab4 commentedThe super administrator user cannot be deleted.
Comment #13
acmoncadab4 commentedAdds uuids filter.
Comment #14
acmoncadab4 commentedComment #15
Prabhu.shan commentedHi,
Thanks for the support. Any idea when this feature (drush command for content_sync) will be available.? Any documentation on the same?
Thanks.
Comment #16
pranay agarwal commentedHi Blanca,
Thanks for such a needed module. I was trying out this module when I came to look out for drush commands. If there is any clarity over the roll out of drush commands, please let us know.
Keen subscriber to this issue.
Thanks in advance.
Regards,
Pranay
Comment #17
geoffreyr commentedJust been trying this patch out, and while it's great to get this sort of functionality going, it doesn't seem to be all the way there yet.
Example command:
drush content-sync:export --entity_types=block_content,menu_link_content --destination=../content/sync/What I'd expect to happen:
What actually happens:
[error] Message: The content directory type 'sync' does not existgets displayedMy expectations are probably a bit out of whack though, so I might try and investigate this to see if there's any further work that can be done here.
Comment #18
geoffreyr commentedI also had problems getting
content-sync:importworking from a directory, because thesourceoption wasn't set up to allow a value. I've attached a patch that tweaks #13 to allow a value for this option. (Sorry about the lack of interdiff, my tools are playing up a bit.)Comment #19
liber_tI have an error in Development version
I replace getLogger with getExportLogger in ContentSyncCommands.php
Comment #20
liber_tI'm sorry my old patch (19) is not good
Comment #21
liber_tI fixed a bug related to the import.
Comment #22
bander2 commentedGetting this error with #21:
[error] Error: Call to undefined function Drupal\content_sync\Commands\drush_prepare_backup_dir() in Drupal\content_sync\Commands\ContentSyncCommands::getDirectory() (line 717 of /var/www/drupal/web/modules/contrib/content_sync/src/Commands/ContentSyncCommands.php) #0 /var/www/drupal/web/modules/contrib/content_sync/src/Commands/ContentSyncCommands.php(213): Drupal\content_sync\Commands\ContentSyncCommands::getDirectory('sync', true)
Looks like drush_prepare_backup_dir is a drush 8 function. Not sure what the drush 9 equivalent is.
Comment #23
klimpRolled out a wrong patch by mistake
Comment #24
klimpComment #25
acmoncadab4 commentedFixes errors:
Comment #26
manuel.adanThis is a really needed feature for this module, thank's. It seems that requires drush 9, patch doesn't work in drush 8. I got a reject in content_sync.info.yml, packaging info was added to the patch:
Comment #27
klimpI didn't get why to rename getExportLogger() to getLogger() in #25
Also, I figured out that the condition
doesn't work but
works fine. Tested against Drush 9
Also added default source option value
This patch stems from #21
Comment #28
acmoncadab4 commentedComment #29
bircherDo you plan to support both drush 8 and drush 9?
If so you should consider putting all the logic in a drush agnostic service and make the drush command very thin just calling the public methods on your agnostic service.
Comment #30
dbjpanda commentedComment #31
adel-by commentedPatch on #27 works fine for me. tested on drupal8.5.5 and drush9
Thanks a lot for this great feature.
Comment #32
ngocketit commentedPatch #27 doesn't work for me. It still exports all content entities, no matter what.
Comment #33
zoltán balogh commentedPatch on #27 works fine for me too
Comment #34
rivimeyComment #35
mxtI used patch #27 with the following instruction:
drush content-sync:export --entity_types=taxonomy_termResult is not as expected:
ALL entities have been exported (so users, nodes, taxonomies), while it would expected to obtain only
taxonomy_termentities exported.Comment #36
blanca.esqueda commentedHi,
Attached the patch that includes the Drush commands for export and import.
IMPORTANT:
Notes:
Refactorization of the code was done and these are some of the features included:
- Organization of the content entities into collections (content type and bundle); This is the reason why the snapshot and the content sync folder needs to be regenerated.
- Partial imports/exports filters: by uuids, entity types & bundles, or actions (create/update/delete).
- Exports: an option to include dependencies in the export is provided (because of partial exports);
- Partial imports: dependencies are checked by default if they exist in the active storage and if not then try to pull them from the content sync folder.
- Files: option to import/export physical files or as base64.
- Cache invalidations per entity imported/exported.
- ...
Documentation about the commands: https://www.drupal.org/docs/8/modules/content-synchronization/drush-comm...
Instead of applying the patch, the branch 8.x-2.x from https://github.com/Blanca-Esqueda/content_sync can be pulled - but note that I'm working constantly in that branch.
Thank you to:
@dabito and @acmoncadab4 for the contribution to the CS Drush commands.
@klimp, the refactoring of the code includes some of your patches.
Comment #37
blanca.esqueda commentedNote:
PHP 7.2 shows an error when installing the module, to resolve it use the patch in:
https://www.drupal.org/project/content_sync/issues/2982986
Comment #38
sozkara commentedI was unable to execute any command:
The drush command 'content-sync:export' could not be found. Run `drush cache-clear drush` to clear the commandfile cache if you have installed new extensions.Both PHP 7.2 and this patch is applied to 8.x-dev branch
Comment #39
steveoriol@sozkara, apparently it only works with drush 9.x, with drush 8.x I had the same problem as you ...
Comment #40
blanca.esqueda commentedYes, it works for Drush 9
Comment #41
sozkara commentedI tried with Drush9 today and have some observations:
1. When first enabling the module it takes a whole lot of time to create the db, as I was importing content from a website with 30k users. I had to locally import and delete the users. There should be an option to bypass some entities when creating snapshot.
2. Some entities gave the following error and drush pm-enable stalled:
I had to delete private message entities although this might be related to corrupt entitites on my part.
3. When enabling the module from the UI, batch processing gave some 500 errors and stalled. drush en seems to work fine.
4. When importing content, the following error happens:
5. On ImportQueueResolver.php line #58 $file_path is hardcoded.
6. When exporting content with --include-dependencies, I got PHP memory limit exceeded Errors:
Hope these inputs help you on this project and thank you very much for your efforts!
Comment #42
blanca.esqueda commentedHi @sozkara
Thanks for testing the drush commands.
I'll try to address 1, 3, 5, 6.
But I wasn't able to replicate 2 or 4, maybe it is related to specific type of content entities..
did you try partial imports? did it work or it was giving you the error in #4 for any type of entity?
did you try partial exports? did it work or it was giving you the error in #2 for any type of entity?
Comment #43
sozkara commentedHello @Blanca
Yes, I'm trying partial imports #2 & #4 like this:
drush content-sync:import --entity-types=node,menuor
drush content-sync:import --entity-types=menuComment #44
mattsqd commentedThis might be an edge case but if you have field permissionson an entity, since this command is running through Drush instead of the UI, the logged in user is the anonymous user instead of whoever started the batch process through the GUI.
I put this in \Drupal\content_sync\Form\ContentExportTrait::processContentExportFiles() and it allowed me to export all fields. I don't know if this is a security risk or if there is a better approach.
Comment #45
wwwprola commentedThe patch works for making Drush commands available to me, but they don't seem to work as expected.
After running export, the list of items to export returns blank. I can't run
--actions=createas it doesn't seem to work with specific only specific entity types, and there far too many entities in the site; I run into PHP Memory exhuasted errors, even at ridiculously high limits.Below is the blank table I receive when trying to export. Am I missing a step?
Comment #46
rivimeyA note about the field permission issue and the UID, there *used to be* an option "-u" to set the user to run as, but this has been removed in Drush 9; for how to do it there, look at #2861591: Export content as user 1 when running in a CLI context
Is there any chnce of an update to the patch, as there looks to be a few niggles? :-) :-)
Comment #47
dimmech commentedThis patch does not apply against the Dev branch as directed on #36. It does however successfully apply on the 8.x-2.1 version and I can confirm that the commands work.
Is there a breaking change to the drush commands for this module in the Dev branch?
Comment #48
aangel commented@dimmech: Alas, just three days later and I cannot get it to apply.
Comment #49
blanca.esqueda commented@aangel, what error do you get when trying to apply the patch?
Nothing has been changed on those branches since days ago so it should still apply.
@dimmech, no.. if I remember correctly in dev there is only a couple of patches more. But nothing that should affect the Drush commands.
Comment #50
murzI have same problem as @wwwprola with empty list on using Drush commands:
And I see no files in content sync folder. Content Sync version 8.x-2.1, Drupal version is 8.7.3, Drush version 9.7.0.
Maybe I need to use only dev version of module for this patch?
Comment #51
adel-by commentedHi @Blanca
File entites are imported, but actual files do not get copied from sync folder to the "files" folder.
I had to set the option
['include_files' => 'folder']on the import command.Also the method
\Drupal\content_sync\DependencyResolver\ImportQueueResolver::depthFirstSearchreferences an absolute path, i assume this is work in progress or a debug code of yours?$file_path = "/Users/Blanca/Sites/devdesktop_opin/do/../content/sync/entities/".$entity_type_id."/".$bundle."/".$identifier.".yml";btw thanks a lot for this useful module!
Comment #52
perarg commentedAs @dimmech and @aangel mentioned, i confirm that the patch #36 or #51 are applied successfully only in 8.x-2.1. In dev version are failed.
I just confirm @wwwprola and @murz about the empty table when
drush content-sync:exportUPDATE: The https://github.com/Blanca-Esqueda/content_sync is working without patches.
Comment #53
tedwyer commentedOne thing I've noticed here is that the drush content sync export command "--entity-types=page or article etc. won't work. But this will; --entity-types=node.page.
If you do an export of --entity-types=node you will get a list of all nodes on the site with the proper node."entity" name. Don't say yes. Hope this helps.
Comment #54
abychkov commented@wwwprola @murz @perarg
The empty table occurs because there is nothing to import to your website because the drush commands except a file structure for the different entities and files. This follows the naming scheme of the .yml files.
A location node will be stores in /sync/entities/node/location, users in sync/entities/user/user, groups in sync/entities/group/groupname, etc.
So you can't just dump the content.tar.gz and unzip it and import it like you can with config.
Comment #55
murz@abychkov, I trying to export content, not import :)
@tedwyer, about
--entity-types=node.page- with #51 patch there are no success:So results are empty, but website have 8 nodes with type "page".
And same empty result for
--entity-types=node..Here is debug and verbose output:
How can I fix this problem?
Comment #56
abychkov commented@Blanca
depthFirstSearch in ImportQueueResolver will go into an infinite recursive loop if you have circular dependencies when importing.
This usually causes the import to hang for ages and then it throws a PHP fatal error of exhausting the available memory. In the web client this usually results in an "ajax http 500 error"
Example
A depends on B
B depends on C
C depends on A
@murz
I had a similar problem at some point and I got around it by unpublishing and then republishing the content.
Comment #57
panshulk commentedFacing the same issue mentioned in comment #55 : https://www.drupal.org/project/content_sync/issues/2873074#comment-13273732
Anyone else also facing this ?
Any idea how to fix this ?
Comment #58
rijidij commentedThank you to all contributors for your work on this module.
@Blanca, any idea when the code on Github mentioned in comment #36 will be merged into the official repo?
Comment #59
druplr commented#51 worked for me except for my existing groups (group module 8.x-1.0-rc4) created before enabling the module. They didn't get exported using drush. But new groups did get exported as expected. Couldn't re-publish groups as @abychkov indicated, at least I don't know how to do that with groups.
To get it working with my pre-existing groups, I exported them manually at
admin/config/development/content/export/singleand saved them atcontent/sync/entities/group/group_name/group.group_name.UUID.yml. Then randrush csi --entity-types=group. Even though the group existed, drush thought it was creating a new group, but it actually updated the existing one (group ID 1), which was intended (drush output pasted below). After that, my groups do get exported as expected.Attaching an updated version of @adel-by's patch with the hard-coded path (
"/Users/Blanca/Sites/devdesktop_opin/do/") removed, as indicated in #51.Comment #60
alessandro.sighnolfi commentedi try to install the last patch,
the patch does't find file.
After i manually check and Miss Drush Service
Thanks
Comment #61
jcnventuraI'm pretty sure that the change in #59 should use content_sync_get_content_directory(CONFIG_SYNC_DIRECTORY) instead of ./content/sync
Comment #62
miguel.leal commentedApplying #59 i had some issues with missing service (content_sync.manager) and wrong entityType declaration, after trying to import the content.
Comment #63
cesardmoro commentedAny of this patches are not running on the dev version downloaded by composer, you have to download from this git https://github.com/Blanca-Esqueda/content_sync to make it work, can you publish this versión to drupal so it download from composer ?
Comment #64
tahiche commentedHi,
I was trying out the patch in "https://www.drupal.org/project/content_sync/issues/2985646" regarding an option for Bulk export an i´m getting the following error:
Error: Call to undefined method Drupal\content_sync\Form\ContentExportMultiple::generateBatch() in Drupal\content_sync\Form\ContentExportMultiple->submitForm() (line 160 of modules/contrib/content_sync/src/Form/ContentExportMultiple.php).This is the line in ContentExportMultiple.php
It seems like the patch is not changing ContentExportMultiple like it does with, say, ContentExportForm where generateBatch() is now generateExportBatch()
This is how the patch changes the function to be called
- batch = $this->generateBatch($entities_list);
+ $serializer_context['export_type'] = 'tar';
+ $serializer_context['include_files'] = 'folder';
+ $batch = $this->generateExportBatch($entities_list, $serializer_context);
I´m going to try and change ContentExportMultiple the same way and see if it works.
Comment #65
rhys commentedI've slightly modified the #62 patch so that it cleanly applies against the 8.x-2.1 version that is downloaded via composer.json.
Comment #66
kwadz commentedComment #68
blanca.esqueda commentedComment #69
blanca.esqueda commentedHi,
8.x-2.x-dev has been updated.
It includes the Drush commands and some other patches.
IMPORTANT:
YAML content entity files and folder tree structure are different from the previous versions as refactoring of code was needed to implement more functionality. 8.x-2.x-dev version has to run on the source and target sites.
Steps to use 8.x-2.x-dev:
Note:
If Drush commands work then we can mark this issue as reviewed and then fixed.
And if needed let's open separate issues for functionality as:
Comment #70
lexa.mihu commentedHi,
I can confirm that
drush content-sync:exportworks now, with dev version.Comment #71
ñull commentedI wanted to test this but after installing I don't see the drush commands anywhere:
Yes I made sure was actually un- and reinstalled, cache cleared.
Is the code not installable through composer?I see the drush.services.yml file so the code OK. What could cause it to remain undetected?Comment #72
drou7 commentedSame as #71, maybe because I am using Drush 8?
Comment #73
robotjox commentedI can confirm that drush commands are not working on content_sync:2.x-dev.Have uninstalled/reinstalled and flushed all caches numerous times.
drush.services.yml is present.
The drush command 'content-sync' could not be found.Edit: Sorry, my mistake - you need Drush 9, then it works
Comment #74
tonytheferg commentedDrush 9 is end of life
Comment #75
liquidcms commentedhaven't dug in too much but this doesnt apply to my version of the module. possibly due to having the 9.x version from here: #3114499: Drupal 9 Readiness
- Installing drupal/content_sync (dev-8.x-2.x 849858f): Cloning 849858fca1 from cache
- Applying patches for drupal/content_sync
https://www.drupal.org/files/issues/2020-09-22/2979368-17.patch (2979368 - ignore types)
https://www.drupal.org/files/issues/2020-04-06/content_sync-drush_comman... (2873074 - drush commands)
Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2020-04-06/content_sync-drush_comman...
[Exception]
Cannot apply patch 2873074 - drush commands (https://www.drupal.org/files/issues/2020-04-06/content_sync-drush_comman...
h)!
Comment #76
blanca.esqueda commentedPlease note the patches were done only for Drush 9 (I tested on Drush version: 9.7.2)

Tried the Drush command with the version that supports D9: 3.0.x-dev
And it works:
I'm marking as fixed this issue - all patches have been added to 3.0.0-Beta1, and 8.2.1.
I'll open a new ticket for Drush Commands [D10]
Comment #77
blanca.esqueda commentedComment #78
lquessenberry commentedHello. I have Drush 9 and Dev 3.x version of this module and I still can't get Drush to recognize the commands. Am I missing something simple like drush updb -y or drush cr?
I can't seem to get it to work.
Comment #79
lquessenberry commentedUpdate, I can now use the drush command, but when I export, nothing happens.
https://dsh.re/6fea2d
What am I missing?
Comment #80
blanca.esqueda commentedDoes the content folder has YML files? if the content folder is not populated most probably the snapshot hasn't been created.
If you exported already once, then there are no differences and nothing to export.
If you are able to use the Drush commands, let's follow the export in another issue.
Comment #81
lquessenberry commentedThank you Blanca. Our call discussing this fixed my issue. It was helpful to remind myself to check fire permissions and folder permissions of the content/sync folder.