PremiumComes with the add-on reqad-account. Installing add-ons
WordPress staging & Push to live
Copy a WordPress site to a private staging site, try updates, plugins and theme changes there, then push the code and the settings you choose back to the live site. The live database is never overwritten, so orders, comments and customers that came in while you were testing are kept.
Staging copy or clone
| Kind | What it is |
|---|---|
| Staging copy | A private copy to try changes on. It sends no email (forms and shops report that sending failed), search engines are asked not to index it (noindex and a robots.txt that disallows everything), WordPress does not update itself and scheduled tasks do not run (DISABLE_WP_CRON), and WordPress knows it is a staging site (WP_ENVIRONMENT_TYPE is staging, which plugins such as WooCommerce read). A banner in the dashboard says it is a staging copy. Only a staging copy can be pushed to live. |
| Clone | An independent second site with the same content, for example to start a new site from an existing one. It keeps the live site's settings and works like any other site. |
Plugins that send through their own service (newsletters, text messages) can still send from a staging copy: switch them off on the copy.
~/wp-backups/ first.Make a copy
- Choose the live site and Staging copy or Clone.
- Enter the copy's address: a new subdomain such as
staging.example.com, or another domain of the account. It gets its own folder (~/staging.example.com), its own database and a free certificate when the name already points to the server. - Optionally tick Only these addresses can open it and list your IP addresses or ranges. Everybody else gets a "temporarily unavailable" page. This is off by default and can be changed later on the copy's page.
- Press Make the staging copy. The copy runs in the background, so you can leave the page.
The copy runs on the live site's PHP version and settings and gets the live site's Security rules. Caches, backups, the object cache and other sites inside the live site's folder are left out. If anything fails, the new site and its database are removed again. A copy counts against the account's disk space and databases.
Push to live
Open the staging copy in Clone or staging and press See what would change. The panel compares the files of both sites by their content and lists:
- Files: WordPress itself, each plugin, theme and must-use plugin, and the translations that differ, with the versions on each side and how many files are new, changed or deleted.
- Switched on or off: plugins you switched on on the copy and the theme you chose there.
- Settings: a few common settings that differ, in groups, each with the live value and the copy's value side by side (see below).
- Uploads: files in the uploads folder that the live site does not have.
Untick what you do not want, then press Push to live. Some items start unticked, so they only go when you choose them:
| Unticked at first | Why |
|---|---|
| A plugin or theme that is only on the live site | It was probably added to the live site after the copy was made. Tick it to delete it from the live site too. |
| A plugin or theme that is newer on the live site | Pushing would put the older version back. |
| A plugin switched off on the copy | Plugins that send email or messages are often switched off on a staging copy on purpose. |
| New uploads | The files are copied, but the live Media Library does not list them: that list is in the database. |
| A setting changed on the live site after the copy was made | Pushing would replace the live site's newer value. |
| WooCommerce store visibility | Pushing "Open to everyone" makes the live store public; pushing "Coming soon" hides it from visitors. |
Settings
The database is never copied, but some settings are what people change on a staging copy and then expect on the live site. These can be pushed, each group all or nothing:
| Group | What it holds |
|---|---|
| Site title and tagline | Settings > General |
| Homepage | Settings > Reading: your latest posts or a static page, the homepage and the posts page |
| Posts per page and feeds, Time zone and date format, Site language | Settings > Reading and General |
| Permalinks | Settings > Permalinks (the address rules are made again afterwards) |
| Discussion settings, Image sizes | Settings > Discussion and Media |
| WooCommerce: store address, currency and units | WooCommerce > Settings > General and Products |
| WooCommerce: store pages | The shop, cart, checkout, my account and terms pages |
| WooCommerce: setup finished | The setup wizard and task list, so the live store does not open the wizard again |
| WooCommerce: bank transfer, check and cash on delivery | The settings of these three payment methods. Other payment methods hold keys that differ between test and live, so set them up on the live site. |
| WooCommerce: store visibility | Coming soon or open to everyone |
A setting that points at a page (the homepage, the shop page) is matched by the page's address on the live site, because the page numbers differ once either site has made pages. When the page is not on the live site, the group cannot be pushed: make the page there first. WooCommerce groups appear when WooCommerce is active on the copy, and go only when it is active on the live site or the same push switches it on.
A staging copy records its settings when it is made, so the panel can tell which site changed a setting since. For copies made before this record existed, every group starts unticked: check the values before ticking.
What happens during a push
- The live site's database is saved to
~/wp-backups/. Every file the push replaces or deletes is moved to~/wp-backups/<site>-push-<date>/. The 3 newest of these folders are kept for each site. - Only the chosen code is copied, and only the files that differ. While the files change, visitors see WordPress's own "Briefly unavailable for scheduled maintenance" page for a few seconds.
- The chosen plugins are switched on or off and the chosen theme is activated.
- The live database is updated in place, as after an update:
wp core update-db, andwp wc updatewhen WooCommerce is active. Other plugins update their own tables the next time they load. Then the settings you ticked are written. - The caches are emptied and the home page is opened. If it opened before the push and no longer does, the old files, the plugin and theme switches and the settings are put back automatically.
A push runs in the background. The live site cannot be updated while a push to it runs, and the copy cannot be deleted while it is being pushed.
Never pushed
- The database as such. Pages and posts, products, menus, widgets, the Customizer, shipping zones, tax rates and most plugin settings are stored there, so make those changes on the live site again. Only the settings groups above can be pushed.
wp-config.php,.htaccessandrobots.txt, which hold each site's own settings.- The staging copy's own must-use plugin, so email and indexing stay on for the live site.
- Caches and other files in
wp-contentoutside plugins, themes, must-use plugins, languages and (when asked) uploads.
Content changes on a staging copy are therefore lost for the live site. So that this is not missed, See what would change lists the products, pages, posts, Media Library items and menu items made or changed on the copy since it was made, and marks those the live site does not have. The copy's WordPress dashboard also shows a reminder on the screens where they are edited. Use the copy for code and design; to move a few new pages or products anyway, export them on the copy (Tools > Export in WordPress, Products > Export in WooCommerce) and import the file on the live site.
~/wp-backups/.Delete a copy
Delete this copy on the copy's page removes its site, files, certificate and database. The live site, including its database, is not changed.
API
The same operations are in the REST API for account tokens: GET/POST /v1/wordpress/{site}/copies, POST /v1/wordpress/{site}/access, GET/POST /v1/wordpress/{site}/push and DELETE /v1/wordpress/{site}. Jobs are followed with GET /v1/wordpress/{site}/jobs/{job}. A push is a job of the live site.
Need a hand? Create a free account or contact us.