backdrop / backdrop-issues

Issue tracker for Backdrop core.
144 stars 40 forks source link

Wordpress to Backdrop CMS Migration #1055

Open serundeputy opened 9 years ago

serundeputy commented 9 years ago

hello.

I'm trying to programmatically take data from a Wordpress DB and migrate to Backdrop CMS DB. The migration runs and puts the data in the Backdrop CMS tables, but the nodes can not be displayed or edited from the the Backdrop UI.

Here is the code: https://github.com/serundeputy/wp-backdrop-migration

I'm guessing there are some node functions that need to be called like node_prepare etc that I'm missing, but I don't have access to the backdrop API functions from the command line without drush.

Any ideas on how to complete these migrations programmatically? Has anyone done a data migration similar to this?

PaulHoza commented 9 years ago

This isn't quite what you're asking, but just in case it helps, I had a setup back in D6 land where I programmatically created nodes from a JSON data feed. I used node_save() at the time after much research and tinkering, but I couldn't likely tell you much more about that decision now without re-researching it. It does seem like I went that route to ease node creation by using Drupal's bootstrapping stuff, but I've never been much of a PHP coder so it was a struggle to get that far.

If you'd like to see my messy script, I could arrange that, but it mostly amounts to loading up an array with all the data for CCK fields, then shoving it into node_save().

I'll dig that stuff up if you think it would help, aside from just the idea. I don't know how that would have been done in D7, tbh, as that project was abandoned-ish.

I did have a working node creation PHP script as well as something where I would load up data to update an existing node. I believe they both used node_save(), iirc.

biolithic commented 9 years ago

I remember Nate talking about Backdrop's object-oriented-ness. It might be $node->save . Might want to check it.

On Wed, Jul 8, 2015 at 7:39 PM, Paul Hoza notifications@github.com wrote:

This isn't quite what you're asking, but just in case it helps, I had a setup back in D6 land where I programmatically created nodes from a JSON data feed. I used node_save() at the time after much research and tinkering, but I couldn't likely tell you much more about that decision now without re-researching it. It does seem like I went that route to ease node creation by using Drupal's bootstrapping stuff, but I've never been much of a PHP coder so it was a struggle to get that far.

If you'd like to see my messy script, I could arrange that, but it mostly amounts to loading up an array with all the data for CCK fields, then shoving it into node_save().

I'll dig that stuff up if you think it would help, aside from just the idea. I don't know how that would have been done in D7, tbh, as that project was abandoned-ish.

I did have a working node creation PHP script as well as something where I would load up data to update an existing node. I believe they both used node_save(), iirc.

— Reply to this email directly or view it on GitHub https://github.com/backdrop/backdrop-issues/issues/1055#issuecomment-119771018 .

serundeputy commented 9 years ago

Thanks @PaulHoza and @biolithic both of your comments are true, but I'd have to have access to the backdrop API to use those functions.

So the answer might be:

All of the answers are fine and the first two would be great, but would take some effort. The 3rd I was just trying to complete an existing migration with the tools that I currently have.

thanks for your thoughts I'll continue to think on it; let me know if you think of something too!

~Geoff

docwilmot commented 9 years ago

I'd export the wp data to an importable format (if the wp export isnt already), like json or xml or csv, then import it in a backdrop module.

quicksketch commented 9 years ago

On using the API directly, you shouldn't need to call node_prepare() at all. You should be able to just make a new node and then save it.

but I'd have to have access to the backdrop API to use those functions.

If I were you, I'd actually bootstrap Backdrop in your migration script. Just use a PHP script that is similar to index.php:

<?php

define('BACKDROP_ROOT', './path/to/backdrop');
require_once BACKDROP_ROOT . '/core/includes/bootstrap.inc';
backdrop_bootstrap(BACKDROP_BOOTSTRAP_FULL);

$node = new Node();
$node->title = 'Foo';
$node->save();

// New node ID:
$nid = $node->nid;
quicksketch commented 9 years ago

Also, I still love to see Drush (and Migrate!) coming to Backdrop. :wink: But if this is a short-term, "tomorrow" kind of problem, a direct script certainly does the job. I did the same thing for a D5 to D7 migration back before migrate existed: http://quicksketch.org/node/5739

serundeputy commented 9 years ago

thanks @quicksketch yes tomorrow problem.

I will try out your bootstrapping suggestions; if I can do that I can probably hit that script ticket for running update.php too :) #820

of course porting drush and migrate will take me longer than tomorrow :)

serundeputy commented 7 years ago

Here is a repo of what I've been working on for import/export of content to and from Backdrop sites: https://github.com/backdrop-contrib/bien

There is much to be done with some kind of UUID system so that we can import/export nodes with file fields etc. where the storage is just a ref id.

klonos commented 7 years ago

Love the name :smile: ...wanted to file a PR that fixed a typo, some occurrences of double spaces and a line exceeding 80 chars limit, but I accidentally committed the changes directly to 1.x: https://github.com/backdrop-contrib/bien/commit/98d8ae4620dcd7a0fd1818e4368bb9d6d22cb8ba

...sorry 😓

olafgrabienski commented 6 years ago

Fyi, there is also a module which "imports a WordPress blog from a WordPress eXtended RSS (WXR) format file", see https://github.com/backdrop-contrib/wordpress_import. (Didn't test it so far.)