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.
Site A Steps
- 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.
- 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.
- 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
- 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.
- 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".
- Set the Fetcher to HTTP fetcher, and set the Parser to XPath XML parser.
- 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.
- 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.
- Make sure the fields in the Node processor match the XML document fields created in SITE A STEP 3
- 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.
- Once you're done. Save your importer and go to /import. Click on the name of the importer that you have just created.
- Type in the URL of the XML document created in Site A. And now you are ready to import content!!
Have questions? Leave them in the comments below!