0

I work with WordPress and I work with git. My code is versioned and I am happy with the workflow.

What bugs me is database synchronization.

I need to work with cloned database on my local development environment so I can easily alter any settings, publish new stuff, etc. In the meantime (say two weeks) when my work is done, I want to push all changes to the production. Git handles the files, but the database is a huge problem...

Option A: I could easily export and import my local database to production, but this would overwrite and/or remove everything that changed on production in the meantime. This is critical especially on blogs or e-shops. I would lost all new posts and orders. So, this is a no go.

Option B: I could somehow export my database data (using either WP export tool or some 3rd party utility) and then import it to production. However, I can't think of any elegant way to really export and import everything (including, new custom post types, custom fields, 3rd party plugin settings, etc.), so this is a no go as well.

I really can't think of any possible way to do this. I have been looking for a way to deal with this for days, with no luck. Even some plugins and utilities that focused on this gave up on development, or are still in early beta states after quite a few years.

WordPress runs on about 1/3 of websites as far as I know. I believe good amount of these websites are large ecommerce stores or news sites, maintained by developers with proper workflow. How do they handle database synchronization?

Edit: This question should not be a duplicate because I am aware of possible solutions mentioned in that question. I actually mentioned those workarounds in Option A and B, but I definitely would NOT consider those as a valid workflow I should be doing.

Edit2: I've come across WP CLI, which seems to have commands to export/import the database, but I didn't read about resolving conflicts at all.

6
  • Possible duplicate of Database synchronization between dev/staging and production Oct 17, 2019 at 11:56
  • @JacobPeattie Please see the edit in my question. Oct 17, 2019 at 12:17
  • I'm very keen to see a comprehensive answer to this myself. Oct 18, 2019 at 3:01
  • I spent quite some time looking for an answer too, but I found no viable tool. In my case the problem is that I have three states: (1) dev (I develop in local), (2) demo (other people does data entry on a temp domain, while I debug locally and push on demo), (3) production. (1&2) are the most sensitive part in this case. My "solution" is to use a shared database online, so that both installations use the same DB. You don't have to synchronize if you use the same DB (insert meme here). There was a promising tool, but very early stage and not working with WPML or other complex plugins.
    – Lorenzo
    Oct 21, 2019 at 8:12
  • @Lorenzo Thank you for the advice, bot not a good solution I guess. How would you handle situations like added new WooCommerce fields (without any functionality on production until you push the new revision), removing/adding/changing some custom fields with outdated templates on production, not yet fully configured plugins and dozens of other scenarios? Also - how do you handle different domain names when using only one instance of the databasr? Oct 22, 2019 at 21:52

0

Your Answer

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

Browse other questions tagged or ask your own question.