2

I'm copying wordpress from my production to my staging site.

I do this by:

  1. copying all files
  2. making a mysql dump
  3. importing mysql dump
  4. updating urls in the database with:

Statements:

UPDATE wp_options SET option_value = REPLACE(option_value, 'http://www.domain.de', 'http://staging.domain.de');

UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'http://www.domain.de', 'http://staging.domain.de');

UPDATE wp_posts SET guid = REPLACE(guid, 'http://www.dailycat.de', 'http://staging.domain.de');

UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://www.domain.de', 'http://staging.domain.de');

Doing this, some of the setting of e.g. the theme, widgets and mailchimp are lost. They are still in the database but they are not showing up on the screens. Any idea how to fix this?

Thanks and I really appreciate your help!

Kevin
  • 41,694
  • 12
  • 53
  • 70
Manuel
  • 9,112
  • 13
  • 70
  • 110

2 Answers2

1

You need to use a script that correctly deserializes/reserializes data in the database, such as serialized data for theme options, widget content, etc. Those UPDATEcommands run in the database won't do that; they do a simple find/replace, which breaks serialized data.

Use interconnectit.com WordPress Serialized PHP Search Replace Tool

Bear in mind that some themes don't correctly serialize data in the first place, so depending on your theme, the script may not fully work, and you may need to reset some theme options, widgets, etc, anyway.

Also see Moving WordPress « WordPress Codex

markratledge
  • 17,322
  • 12
  • 60
  • 106
  • thx, gonna check this tomorrow. Probably use sta instead of staging as subdomain. I think find and replace should work than, since www and sta have the same character length or? – Manuel Jul 22 '14 at 01:05
  • I think some php serialized data won't break using those straight SQL queries, if both the original and replaced strings are the same length. – markratledge Jul 22 '14 at 03:15
0

If you want to migrate your website you can do all these serializes and deserializes with the plugin WP Migrate DB semi automatically. With its use you only have to define the strings you want to convert,

If you just want to create an independent staging site, no matter where it is located you can use a wordpress plugin like WP Staging that does all necessary converting and migrating operations automatically for you.

Rene Hermenau
  • 323
  • 1
  • 9
  • The WP Staging plugin does not solve the OP's problem of migrating WP data from a separate Staging site to a Production site. This plugin simply creates a "Staging" subdirectory within the existing installation. – Magellan Aug 28 '15 at 22:18
  • @Magellan you are right. Thanks for pointing this. I corrected my answer. – Rene Hermenau Aug 31 '15 at 09:33