[00] Subset Sync, User guide
Pushing staging to live
Last updated
Why a database push from staging overwrites live orders, comments and users, which tables Subset Sync can leave out, and an order of work that keeps live data.
A database push from staging to live replaces live’s tables with staging’s. Every order, comment and user that live gained since you made the staging copy is lost, unless you leave that table out. Subset Sync can leave out tables you choose, but it doesn’t merge rows. It always replaces options, users and usermeta. This page explains what a push replaces, what stays on live, and an order of work that keeps live data.
Why a push overwrites live data
A staging site starts as a copy of live. From then on the two drift apart. You change pages, settings and plugins on staging, while live keeps taking orders, comments and new accounts. Push staging’s database back and live’s copy of every table goes, including the rows only live had.
Subset Sync builds staging’s tables next to live’s under temporary names, then swaps them in with a single RENAME TABLE. Each table in the push is replaced whole. Nothing is compared row by row. The preview says so before you start: “The database holds the posts, pages, comments, users and settings, so the destination’s copies of those are replaced.”
The data you’re most likely to lose lives in these tables:
| Data | Tables | Can you leave it out? |
|---|---|---|
| Comments | comments, commentmeta | Yes |
| Users and customers | users, usermeta | No, they’re always pushed |
| Settings | options | No, though a few options stay with live |
| Posts and pages | posts, postmeta | Yes, but your content changes stay behind too |
| WooCommerce orders | WooCommerce’s own order tables, or posts and postmeta, depending on how your store stores orders | Yes |
What selective sync means
Selective sync means moving only part of a site instead of all of it. It can work at three levels:
- By type: the database, the media library, or themes and plugins
- By table: some tables, with the rest left as they are
- By row: merging only the rows that changed, so both sites’ new data survives
Subset Sync works at the first two levels. It doesn’t merge rows, and it doesn’t sync in both directions.
What Subset Sync moves and what stays on live
- Database. Every table on staging, unless you leave it out. Tables you leave out stay on live as they are.
- Tables only live has. A table that staging doesn’t have, such as one from a plugin installed only on live, isn’t touched.
- Settings that stay with live. Its Subset Sync connection settings and saved connections,
home,siteurl,upload_path,upload_url_pathandblog_public, and Subset Sync’s own activation. A developer can add options to that list with thewpmig_preserved_optionsfilter in the developer reference. - Media library. Tick Media library (uploads) to copy new and changed files. Nothing on live is deleted unless you tick Delete files on the destination that aren’t on the source. Untick Database to push media only.
- Themes and plugins. The free plugin never moves them. Subset Sync Pro pushes theme and plugin files without touching the database.
Before a push replaces live’s database, Subset Sync backs it up on live, unless you turn the backup off.
Leave tables out
- On the Migrate tab, choose Push and pick the live site.
- Open Advanced options. Under Leave out, the tables list shows every table on staging with its rows and size.
- Untick the tables live should keep, such as
commentsandcommentmeta. Core tables are marked Always migrated and can’t be unticked. - Click Preview push. The preview lists the tables you left out as “Left out (destination’s own copy stays as it is)”.
On the command line, --exclude-tables leaves tables out, and --tables pushes only the tables you name plus the core ones. Use one or the other, not both. Names go without the table prefix, and * and ? work as wildcards:
wp subset sync push Live --exclude-tables="comments,commentmeta" --dry-run
Naming a core table in --exclude-tables stops the push with an error before anything changes.
Leaving a table out keeps its rows, but those rows can point at rows in tables you replaced. A comment kept on live belongs to a post ID, and an order belongs to a customer’s user ID. If staging’s posts or users table doesn’t have that ID, the kept row points at nothing, or at something else. Customers who signed up on live after you made the staging copy lose their accounts, because users is always pushed.
An order of work that keeps live data
Push only what changed.
Only code changed. Don’t push the database. Push the theme and plugin files with Pro, or deploy them your usual way:
wp subset sync files push Live --themes=my-theme --dry-run
Settings live in the database, so redo any settings changes on live by hand.
Only media changed. Untick Database and push the media library, or run wp subset sync push Live --media-only.
Content or settings changed, and live keeps taking orders or comments.
- Pull live into staging right before you start, so staging begins with live’s latest data.
- Make your changes on staging, and keep the window short.
- Stop new orders, comments and sign-ups on live while you push. Subset Sync has no maintenance mode, so use your own.
- Run
wp subset sync diff Liveto see how far the sites have drifted since your pull. It lists tables that only one site has and tables whose row counts differ. The counts come from MySQL’s table status, which is an estimate for InnoDB tables, so treat a difference as a hint and check the tables it names. - Preview the push, check the tables and the backup, and run it.
If the diff shows orders or comments that only live has and you can’t stop live, push less. Leave those tables out, or redo the content changes on live by hand.
If you overwrite something
The backup taken before the push sits in live’s Subset → Migration → Backups tab. Restoring it puts back live’s whole database as it was before the push, including the orders, and undoes the push. Restoring is a replace too, so anything that happened on live after the push is lost. See backups and history.
To make an accidental push harder, tick This is a production site on live’s Connection tab. A push then asks you to type live’s domain first. To refuse pushes to live entirely, untick Push to this site.