Skip to content

Staging WooCommerce without syncing order tables

Web Hosting by moebig 13 replies 1.6K views
#11

I keep thirty client sites and I do this differently. No plugin, just mysqldump with --ignore-table for the order tables, then sed for the site URL. Takes five minutes to script.

The problem with "smart" plugins is they hook into WordPress, which means they load WooCommerce, which means they can trigger actions. I've seen a staging sync fire wc_reduce_stock_levels because a product save hook ran during import. On a live site with shared inventory. Client was not happy.

My way is dumb and reliable. The database does not run PHP.

#12
harbourops said:
Mysqldump with --ignore-table

This is what I do too but my upload speed is 3 Mbps on a good day. A full dump with exclusions is still 800 MB for one of my shops, takes all night to pull down. Plugin that runs on the server and does selective export to a file I can wget is worth it for me.

I modified moebig's plugin to stream to S3 instead of local file, because my server has 100 Mbps up and I do not. Different problems in Manila I guess.

127.0.0.1 is where the heart is
#13
harbourops said:
The database does not run PHP

This is the way. I wrote a bash script around mariadb-dump that also handles the search-replace with a temporary table and UPDATE, no sed needed for serialized data. Uses wp-cli for the URL replacement after, because wp search-replace handles serialization correctly.

It's on my git if anyone wants. Not a plugin, a cron job. Runs at 3 AM, emails me if the row counts don't match expectations. Gentoo taught me to distrust anything that loads more than necessary.

oops: 0000 [#1] SMP
#14

Following this thread. I tried WP Staging Pro and it broke my order emails, the staging site was somehow still pointing at the live SendGrid API key and customers got duplicate "your order is processing" mails at 2 AM. Not the same problem exactly but related, the wp_options contamination.

How do you all handle API keys and webhook URLs in staging? Separate list or just manual after sync?

Post a reply

You need an account to reply. Log in or register to join the conversation.

Post reply Preview Save draft