Sync plugin settings (wp_options table) on multiple environments

How do you guys handle database changes, more specifically the settings (wp_options)?

Im looking for something like, having a JSON file (or migration files bit similar like Laravel) with settings, that I can run after a deployment.

For example once I install WooCommerce I have a list with default settings (presets) I want to use and import at once. But also once I add a new feature or plugin that I can migrate those settings across multiple environments.

Would be cool if that JSON file (or settings file) is environment based. So I can use test payment method settings on local and live settings on production. And just run a command like wp migrate options or something in my deployment script, which sets all the correct settings for that environment.

Is there something like that?

Thanks in advance :)

Topic sync Wordpress

Category Web


This is a tricky one since even if you might get it to work with Core with plugins you never know if they also store data in files, custom tables, post types and so in. If you then only sync the options table you might get inconsistent/partial/broken states. Also you probably don't want to sync everything since some things like transients are on the options table but aren't really settings.

This is a general problem with systems that store configuration in the database and even more so with WP since the data storage formats are somewhat fragile.

If you search the web or this site you'll see that there have been plenty of questions and attempts of approaching this. But there is no general best practice solution to it.

Having said that, concerning your specific request you can have a look at https://github.com/danielbachhuber/dictator which looks like it is unmaintained but might give you a head start on one possible approach.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.