Content Migration From One Drupal 7 Site to Another

contentmigrationdrupal 7

Content Migration From One Drupal 7 Site to Another

I have first hand experience dealing with content migration, and let me tell you, it can be frustrating sometimes. If you're tired already and you're looking for ways to migrate content between Drupal 7 sites, then you are in the right place. I'm going to walk you through the steps that I had to do in order to get 500+ nodes seamlessly migrated from one Drupal site to another.

Before I start I would like indicate that I have tried using different ways, but with no luck! I tried using Node Export module and I also tried using Deploy module, but I guess the sites I've been working on were too complex or too unstable for them to function as expected. For example, the deploy module kept breaking the site whenever I attempt to fetch content, while node_export was failing silently, I submit the import form and it just reloads without doing anything at all, no errors, nothing.. Very frustrating.

So eventually I did it with XML Syndication. Here's how.


XML Syndication is the concept of having Site A's content, available through HTTP as an XML feed so that Site B can fetch, parse, and import the content. Just like an RSS feed, but more customized.

This method allows for importing one content type at a time, and it supports most field types.

Module Dependencies

Site A Steps

  1. Create a new Feature and include the content type to be migrated, along with all its field definitions; in order to replicate them on Site B.
  2. Create a new view. Add a Page display and set a path for it. Using the  Views Datasource plugin set the FORMAT to "XML data document". In the FORMAT settings, make sure to set a meaningful name for the "Top-level child element" because we're going to need it later. Don't use a pager and set the view to display all nodes.
  3. Test your view page, and make sure it displays a valid XML document that lists all the nodes to be migrated correctly.

Site B Steps

  1. Copy the Feature that you have just exported from Site A to Site B's sites/all/modules folder, and enable the feature. This should replicate the content type and all its fields.
  2. Go to /admin/structure/feeds and add a new Feed Importer. In the Basic settings of it, set "attach to content type" to use a standalone form, and check the box that says " Import on submission".
  3. Set the Fetcher to HTTP fetcher, and set the Parser to XPath XML parser.
  4. Set the Processor to Node processor, and then click on its corresponding Settings. Set the "Bundle" to the content type that was created by the Feature earlier. Set the desired Author, and disable the "Expire nodes" option. You can also choose how you want to treat existing nodes, but note that this will require you to choose a "Unique Field" in the next step.
  5. Click on the Node processor - Mapping link, and add all the content type fields as targets and set their source to "XPath Expression". Choose the field that should be unique if needed.
  6. Make sure the fields in the Node processor match the XML document fields created in SITE A STEP 3
  7. Click on the Parser settings and set the XPath expressions so that the expression in each field points to the corresponding field in the XML document. Here is an example of XPath Expressions format. In the example, the context //r  refers to the "Top-level child element" we talked about in SITE A STEP 2.
  8. Once you're done. Save your importer and go to /import. Click on the name of the importer that you have just created.
  9. Type in the URL of the XML document created in Site A.  And now you are ready to import content!!

Good Luck!! 

Have questions? Leave them in the comments below!

Related Posts

Redesign Your Site: Why Is Migration So Complex?

Kendall Westbrook
Read more

Creating content types in Drupal 7

Tom McCracken
Read more

Socialize Your Drupal Site in 5 Easy Steps

Tom McCracken
Read more

Drupal 7 Content Types Demystified

Tom McCracken
Read more

Adding & editing content in Drupal 7

Tom McCracken
Read more

Synchronize one drupal site with another using Drush

Dustin Currie
Read more