Treat the live site as the single source of truth for content and the staging site as the source of truth for code, and only ever move each in one direction. Content flows down from live to staging when work starts, and code, themes and configuration flow up from staging to live as a planned release, so you never have to merge two databases.
That one rule removes most of the pain of a client adding pages on live while changes are built on staging.
## Why the two way sync keeps failing
A website is really two things travelling together: the code that makes it work and the content people add every day. They change at different speeds and are owned by different people. The developer owns the code. The client owns the content. When a team tries to sync whole databases in both directions, it is asking one copy to be right about both at once, and on a busy site that is rarely true for more than an afternoon.
John Sansbury makes a useful point about the word deployment in The Journey to Service Excellence: "Although it is conventionally used to refer to moving something to a live environment, it actually refers to moving from one environment to another." Seen that way, refreshing staging from live is a deployment too, and it deserves the same small amount of care.
## Practical steps
- Write down the direction of travel. A short note for each site saying "content: live to staging, code: staging to live" settles most arguments before they start.
- Refresh staging from live at the start of each piece of work, not at the end. Copy the live database and media down, then rewrite the site address so staging points at itself. On WordPress, the WP-CLI search-replace command is built for this, and its project documentation says it handles PHP serialised data, which a plain find and replace on a database dump can break. Run it as a dry run first.
- Keep code in version control and release from there. Push themes, plugins and configuration to live from the repository, never by copying files from one server to another. John describes the principle behind this as a release that "is always taken from this source (as opposed to taking a copy of a copy)."
- Agree a short content pause for big releases. If a change touches page structure or custom fields, ask the client to hold edits for an hour or two while you deploy. For routine theme or plugin changes, no pause is needed because you are not touching their content.
- Move client drafts item by item. If the client has prepared new pages on staging, export or recreate just those pages on live. Do not push the staging database over the top of live to save time.
- Take a backup of live immediately before each release and check you can restore it. Then decide in advance what you will do if the release goes wrong. John notes that what used to be called a back out plan is now a remediation plan, because "it is not always possible to back out of a change; sometimes it is necessary to move forwards." Once real customers have submitted forms or orders on live, rolling the whole database back may lose them, so a fix forward is often the safer choice.
- Protect staging properly. Keep basic authentication or an IP allow list on it, and stop search engines indexing it, so that test content never competes with the real site.
## A short worked example
A small agency looks after a dozen brochure sites for local businesses. One client wants a new services section built while their office manager carries on adding news posts on the live site. On Monday the developer refreshes staging from live, builds the new section and its templates, and shows the client on the protected staging address. On Thursday the client approves. The developer takes a backup of live, deploys the theme and plugin changes from the repository, and then creates the four new service pages directly on live using the approved copy. The news posts added that week are untouched, because the live database was never overwritten.
## Common mistakes
- Pushing the staging database to live, which quietly deletes everything added on live since the last refresh.
- Letting the client edit content in both places, so there are two versions of the truth.
- Running a plain text find and replace on the database, which can corrupt stored settings.
- Skipping the backup because the change "is only a plugin update".
- Leaving staging open to search engines and the public.
## Keeping it proportionate
None of this needs heavy process. For a handful of small sites, a repository, a backup and a clear rule about which way content and code travel is enough. The aim is the balance John describes for any release policy: enough stability that the client trusts the live site, and enough flexibility that changes still ship quickly.
For the wider good practice on change and release, see PeopleCert's ITIL guidance and the service management standard ISO/IEC 20000.
If this helped, John Sansbury's The Journey to Service Excellence covers release and deployment management, release policy and remediation planning in depth, and is available to Exchange members.