Drupal - Is there a way to migrate only nodes?

You don't need to do a full migration. You can initialize the Upgrade process by connecting to the old site and it will create migrations. Then you can, instead of executing them automatically, run just some of them with the UI provided by the upgrade_tools project ( I think?).

However, migrations have dependencies. To be able to run the node migration, by default you have to run a few others, e.g. users, text formats and also the fields.

You can try to change that by editing the created migrations either with drush cedit or export/import. I believe someone is also working on an UI for it.

You can also customize any mapping and how fields are migrated. The default behavior is that every field and configuration is migrated 1:1 but to be honest, I can't imagine that's what most sites will want to do. Instead, I imagine they build a new D8 site and then import the content.

See the migration documentation. There are also plenty of blog posts available already around that topic but it's not a trivial thing to do.

  • https://drupalize.me/blog/201511/simple-drupal-7-drupal-8-migration
  • https://www.advomatic.com/blog/transforming-data-in-a-drupal-8-migration-step-by-step

Alternatively, you can try to export/import your content, as mentioned in the Comments, Feeds is not quite ready yet, but you could use a views export and import by writing some custom code.


Migration is a bit heavy weight for this. In drupal 7 there were some modules for only import/export of content. In drupal 8 I couldn't find any that is ready yet. So I improvised with a bit of code:

I did an export in drupal 7 with views to csv with the help of the module:

views_data_export

In drupal 8 I've used the php-library:

parsecsv-for-php

And this code:

require_once('parsecsv.lib.php');
$csv = new parseCSV();
$csv->auto($filepath);
foreach ($csv->data as $key => $row) {
  $node = entity_create('node', array('type' => 'article', 'title' => $row['title'], 'uid' => $row['uid']));
  $node->langcode->value = 'en';
  $body = $row['body'];
  $body = str_replace('http://host1.com/', 'http://host2.com/', $body);
  $node->body->value = $body;
  $node->body->format = 'full_html'; 
  ...
  $node->save();
}

The advantage is, that you can make your own adjustment, like replacing paths from drupal 7, or set a fixed language. And you can check if all dependencies are met, for example that the uid is already there.

Tags:

Migration

Nodes

8