Backups are where I keep running into the same failure. The backup exists, it runs nightly, and something is still lost after an incident. Usually the tool did its job. It just copied something slightly different from what the shop owner assumed it was copying.
Five things that decide this.
1. Your host's backup is not your backup
Almost every host advertises a daily backup. That protects you against your own mistakes and does nothing when the failure is on the host's side, because the copy sits on the same infrastructure as the shop. If the account disappears, the backup goes with it.
Then there is retention. Seven days sounds reasonable until a plugin has been corrupting prices for three weeks and the oldest copy you can reach is already poisoned.
A second copy, off the server and with a different provider, is the minimum for a shop someone lives off.
2. Orders no longer live where they used to
For years WooCommerce kept orders in wp_posts and wp_postmeta, mixed in with pages and blog posts. For several releases now the default has been HPOS: separate wc_orders, wc_order_addresses, wc_order_operational_data and wc_orders_meta tables.
If you have a hand-rolled script that exports a fixed list of tables, written before HPOS landed, it is backing up a database with no orders in it and nobody has noticed. After a restore the shop comes back up, the catalogue works, and the order history is empty.
Checking takes a moment:
wp db query "SELECT COUNT(*) FROM wc_orders;"
wp db query "SELECT COUNT(*) FROM wp_posts WHERE post_type='shop_order';"
A large first number and a zero second one means the shop runs on HPOS and your backup has to cover those tables.
3. Orders arrive while you are restoring
This is the one that hurts. The shop goes down on Saturday morning, you restore last night's copy, and everything comes back. So does the gap: every order placed between midnight and the outage is now gone, because the copy never knew about them.
The customer paid, the payment provider has the transaction, and the shop has no order. You find out from the customer, usually days later.
There is no elegant fix beyond one. Before restoring, export whatever the live database still holds past the backup's timestamp, then load it back once the restore is done. If the database is unreadable, the payment provider's dashboard is your only record of that window.
This is why on a shop with real turnover the database backup interval is measured in hours rather than days.
4. A backup nobody has restored is an assumption
An archive that gets created and weighs roughly what it should is still not proof you can stand the shop back up from it. Dumps get truncated by timeouts. Copies miss tables with a non-default prefix. Archives look complete while uploads was cut short by a time limit.
Restoring onto a test environment once a quarter answers the question you cannot close any other way: how long does this actually take. You want that number before a client asks when the shop will be back.
5. Files grow faster than the database
After a few years a shop database is usually a few hundred megabytes. The uploads directory can be tens of gigabytes, because WordPress keeps every uploaded image in several sizes and plugins add their own on top.
At that size a full nightly file copy stops making sense. Database daily or more often, files incrementally, a full image less frequently. It is also worth walking through those gigabytes once to see how many are still in use.
Four questions worth answering first
- Where does the copy physically live, and what happens to it when the hosting account goes away.
- Does it include the
wc_orderstables, if the shop runs HPOS. - How many orders fit in the window between copies.
- When did somebody last restore the shop from that copy for real.
If any of them needs guessing, that is the first thing to fix.
I'm Wojciech Duraj and I run initSoft. I build WooCommerce stores and do WordPress maintenance for companies with no in-house IT team. Both pages are in Polish, which is where I work, remotely across the country.
Top comments (0)