Migrating Nodes and Taxonomies, as well as CCK and Views Definitions, Between Drupal Instances
In my previous Headless Drupal post, I proposed ways to work with Drupal content programmatically, particularly for bulk tasks like updating many nodes.
A question was raised in a comment on that post as to how to use that information to migrate content between instances of Drupal, and in particular how to handle file attachments on nodes, especially if they are large.
I have to admit that I haven’t had to solve this exact problem often, and when I did in the past, it was with basic page nodes. My initial reaction is that the techniques explored in my Headless Drupal post may not be the best fit for this task. I view this task as a basic import/export problem, and from my past experience, I know of contributed modules that specifically address this need, so I decided to reacquaint myself with them in an effort to provide a set of options for solving similar problems.
Node Content, Taxonomies
I’ve used the Node Import module in a Drupal 5 site some time ago, and although it states that it is a “work in progress” for Drupal 6, it directly addresses the issue of bulk importing nodes into Drupal. You can use the capabilities provided by the Views Bonus module to export nodes from one Drupal instance to CSV that the Node Import module can then import into another Drupal instance.
The Node Import module can handle many node types, users and taxonomy vocabularies and terms. It can also handle some CCK fields and nodes defined in contributed modules. Refer to the Node Import module site for a complete list of its capabilities and limitations.
The main limitation of Node Import is that it does not handle files attached to nodes. For this limited purpose, I think you could effectively supplement Node Import with the programmatic approach outlined in the Headless Drupal post, possibly even just batch uploading the attached files themselves from one Drupal instance to the other manually via FTP, as Drupal simply stores files on the filesystem.
If you simply want to work with taxonomies in Drupal, the more specialized Taxonomy Import/Export via XML module module is worth looking at. I’ve personally used this module to export taxonomies, although I haven’t used it to re-import them into another Drupal instance.
Another benefit of the Node Import, Views Bonus and Taxonomy Import/Export via XML modules is they allow you to flexibly interact with Drupal via standardized file formats such as CSV and XML. This capability alone makes these modules much more generally useful for a wide variety of other tasks.
CCK and Views Definitions
If you simply need to move your CCK node definitions between Drupal instances, the Content Copy sub-module that comes with CCK can do this.
Similarly, the Views Exporter sub-module that comes with the Views module can be used to move views definitions between Drupal instances.
Drupal Services Module
The Services module is another possibility for interacting with Drupal, although I have to admit that I have not used this module yet, so I don’t know about its maturity, flexibility, strengths, etc. Still, it looks like it fits with this general topic, so for the sake of completeness, I thought I should mention it.
In the not-too-distant future, I may have a project in which I will need to connect Drupal with a digital preservation repository, and at that time, I will be looking at the Services module as a possible framework for that development. If I end up using the Services module, I’ll write about it on this blog for the benefit of others.
This work is licensed under a Creative Commons Attribution - ShareAlike 2.5 License.