Forum

Thread tagged as: Question

Import Content from another perch site

How do I import Perch content data (not blog) into a new Perch site via MySQL / PHP?

I've managed to make a MySQL export of the most recent revisions only. Now I get something like this:

INSERT INTO `perch2_content_items` (`itemRowID`, `itemID`, `regionID`, `pageID`, `itemRev`, `itemOrder`, `itemJSON`, `itemSearch`) VALUES
(1627, 3, 1, 1, 63, 1019, '{"_id":"3","link":"example.ch","_title":"example.ch"}', ' example.ch '),

Easy:

  • Set regionID and PageID to a the desired values, reset itemRev

Challenges:

  • Set right itemOrder (necessary?)
  • Set new itemRowID
  • Set new column itemID and the identical JSON value "_id"

Is there a basic PHP snippet to start with?

Urs Bräm

Urs Bräm 1 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

It would be easier to import the entire set and then set PERCH_UNDO_BUFFER low to remove all the revisions you don't want.

Ok, and how should I do the import? Can you give me something to start with?

Drew McLellan

Drew McLellan 2638 points
Perch Support

mysql -u username -p -h localhost dbMyDatabase < dumpfile.sql

:-)

and that won't make any issues with all the IDs? I had been worrying about itemRowID, itemID and "_id" in JSON.

Just dump it in, MySQL will handle everything?

I'm tempted to try right away

Ah probably I was misleading in my first post. I meant, into an existing site.

I wrote "new" site because that's my current use case, but there is some content already present.

I'll rephrase:

How can I import one region's content into another, existing perch site?

Thanks for your patience

Rachel Andrew

Rachel Andrew 394 points
Perch Support

I don't think we have a solution for that, it's not a usual thing people want to do.

Ok, I'll post a suggestion