5

Help me solve this scenario,

Assumptions:

  1. Two users user1 and user2 are using their own copy of Drupal site - site1 and site2 on their respective machines.
  2. They use same set of contributed modules (possibly with different configuration of the modules).
  3. Both users add about 300 pages each to the sites.

Now, it is decided that the organization will use the site of user2 and migrate it to the production server. The organization also wants the pages created by user1 to be added to the site created by user2. How can this be done without changing the configuration of the site?

I did use the Backup and Migrate module to migrate the site site2 of user2 to the production server. Now, I am having difficulty in adding the content of site1 created by user1 to the production site; because if I use Backup and Migrate module again it will overwrite the existing pages from the site. It will also change the settings of the modules stored in the database. It is because, the nodes (pages) on site2 and site1 will have nids starting from 1 and auto-incrementing in the nodes table. So, doing a backup and migrate procedure will replace nid=1 from site2 with nid=1 from site1.

Is there a way so that I could append nid from the old database to new?

What other options do I have?

4 Answers 4

2

You need to migrate the content of site 1 keeping the config of site 2. My recommendation is to use migrate module coz I prefer it. But you'll have to write code to use migrate module.

There are other modules that may help you like node export, deploy. You can also write custom script but I have had most success with migrate module. You might need to justify the use of migrate in comparison to the content to be migrated, because you'll need to write migration classes but for lets say 300 nodes I'd still use migrate.

I wrote an answer sometime ago which talked about migration of content, users, categories etc. See if it helps you to choose as well - Updating content after major upgrade from 5 to 6 (changes to production site need to be reflected in dev environment)

1
  • 2
    which things do I need to keep in mind when writing my code for migrate module for this particular scenario?
    – AjitS
    Commented Jun 14, 2012 at 11:26
2

I would recommend using the deployment module. It was develop by Al Jazeera for a similar but more complex workflow. It is extremely beneficial for sharing content amongst multiple sites and setting up automated syncs. However, in your case you will be able to quickly set up a deployment plan and run it once to get the content from one site to the other with out impacting settings and other data stored in the database. Deployment requires both services and uuid. It's not to difficult to setup and is extremely useful for deploying content amongst multiple sites or setting up a staging environment. You can find the documentation here.

0
1

You need to take care of node revision table as well. You need to write a procedure that does some thing like this in MY SQL

INSERT INTO node_revisions (nid,uid,title,timestamp,body,teaser,log) nid = 0
v = GET VID from last inserted row
INSERT INTO node (vid,type,title,uid,created,changed,status) vid = v
x = GET NID from last inserted row
UPDATE node_revisions SET nid = x WHERE vid = v

By doing this you will end up with new set of nid and vid with same content. I wanted to do the same some time back tried Deploy module but ended up writing my own scripts.

6
  • 3
    I think playing with database directly would not be a good idea! And yes, I'm using node revisions as well, that would make the process even more complex. If I miss even a single dependency while updating, it would create more complications :-/
    – AjitS
    Commented Jun 14, 2012 at 14:21
  • no its not that complex all you need is a new set of nids and vids. This is how I did it and it worked out fine :)
    – GoodSp33d
    Commented Jun 14, 2012 at 16:48
  • 2
    This will work fine on a simple site, but as soon as you start throwing CCK and other contributed modules into the equation, this method will break down fairly quickly. Commented Jun 19, 2012 at 15:58
  • We have 400 tables mate :) Its not that complex. I removed few steps and stripped down to common and required ones. Next step here would be to add to CCK tables.
    – GoodSp33d
    Commented Jun 19, 2012 at 17:42
  • As a general rule of thumb you should never directly edit the database Drupal runs on. Commented Sep 11, 2015 at 13:47
1

Also a shout-out for Feeds, which basically aggregates one site into another.

UUID-based solutions are much better, however, given that they'll allow you flexibility later on as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.