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.

Where: in the account panel (port 2083), WordPress Toolkit > Clone or staging. Choose the site at the top of the page. In WordPress Toolkit > Sites, each site also has a copy button, and copies are marked Staging copy or Clone.

Staging copy or clone

KindWhat it is
Staging copyA 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.
CloneAn 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.

Live site example.com Files WordPress, plugins, themes uploads, wp-config.php Database posts, pages, products orders, customers, settings Staging copy staging.example.com Files WordPress, plugins, themes uploads, wp-config.php Database posts, pages, products orders, customers, settings 1 · copy: all the files 2 · push: code only, what differs 1 · copy: its address changed never pushed: new orders stay
A staging copy is a new site with its own files and database. Push to live sends back only code (WordPress, plugins, themes, translations) and the settings groups you tick. The live database is updated in place, never replaced, so orders, comments and customers that arrived while you tested are kept; it is saved to ~/wp-backups/ first.

Make a copy

  1. Choose the live site and Staging copy or Clone.
  2. 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.
  3. 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.
  4. 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 firstWhy
A plugin or theme that is only on the live siteIt 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 sitePushing would put the older version back.
A plugin switched off on the copyPlugins that send email or messages are often switched off on a staging copy on purpose.
New uploadsThe 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 madePushing would replace the live site's newer value.
WooCommerce store visibilityPushing "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:

GroupWhat it holds
Site title and taglineSettings > General
HomepageSettings > 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 languageSettings > Reading and General
PermalinksSettings > Permalinks (the address rules are made again afterwards)
Discussion settings, Image sizesSettings > Discussion and Media
WooCommerce: store address, currency and unitsWooCommerce > Settings > General and Products
WooCommerce: store pagesThe shop, cart, checkout, my account and terms pages
WooCommerce: setup finishedThe setup wizard and task list, so the live store does not open the wizard again
WooCommerce: bank transfer, check and cash on deliveryThe 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 visibilityComing 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

  1. 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.
  2. 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.
  3. The chosen plugins are switched on or off and the chosen theme is activated.
  4. The live database is updated in place, as after an update: wp core update-db, and wp wc update when WooCommerce is active. Other plugins update their own tables the next time they load. Then the settings you ticked are written.
  5. 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, .htaccess and robots.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-content outside 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.

The database backup is never put back automatically, because by then the live site may hold new orders or comments. To go back after a push, import the database backup with phpMyAdmin (Databases > phpMyAdmin, Import). The replaced files are in the push's folder in ~/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.