Skip to main content
TrustServers Knowledge Base

Tip: Start typing to get instant search results.

Table of Contents

Magento 2 Automatic Synchronization Tool: Live Website to Staging

A common need in the development cycle of a website is synchronizing the live website to a second installation (dev, test, staging), in order to test new features in the staging environment before they are applied to the live website.
Therefore, there is a regular need to create a “clone” copy of the live website to the staging website, so that testing can be done on an updated copy of the live website.

For this purpose, we have developed an automation tool that, when executed, synchronizes your live Magento installation to your dev/staging installation, regardless of whether the different environments are on the same or different servers.

Running the Magento 2 Synchronization Tool

  1. To start updating (synchronizing) your staging environment from live, simply run the synchronization tool. On the server running your live Magento, execute the following command in SSH:
    ts_synclive2stage

    It doesn’t matter which directory you are in when you run the command.
    Note that the tool will not change anything in your live Magento installation.

  2. The tool starts, and if you have multiple testing environments available (e.g., dev, staging, test), it asks you to select which environment you want to synchronize to. Example:
  3. Next, you need to answer “Yes” or “No” (Y/N: Yes/No) to the questions that appear, where you select in detail what you want to synchronize.
    Example screen you will see:What the options mean:
    • Transfer Database (Y/N): Do you want to synchronize the database from your live website to staging?
    • Transfer Files (Y/N): Do you want to transfer all files from the live website to staging?
    • Transfer Catalog Media (Y/N): Do you also want to synchronize the Magento catalog images – files in the pub/media/catalog/ subfolder? Since these images often take up a large amount of space and not all are needed in a staging installation, you can answer “No” to this question so that the pub/media/catalog/ subfolder of Magento 2 is not synchronized.
    • Auto deployment & reindex (Y/N): Do you want the tool to execute the necessary Magento commands for full deployment as well as reindex in the staging environment after synchronization? Yes (Y) is recommended.
      Note that the tool takes care, among other things, to automatically change the prefix for ElasticSearch/OpenSearch so that it differs from the live one.
    • Final confirmation (Y/N): Final confirmation for the synchronization to begin and a reminder from the tool that existing data in the staging installation (Database and/or files) will be deleted as new files will come from the live installation.
  4. The tool will start the synchronization, providing you with detailed information about the steps it performs and their progress. Example:

After Synchronization

If you use a Magento extension that has a separate cache specifically for your website’s main menu, you need to flush the menu cache and then flush all caches again before using your new staging website.

Was this article helpful?
Please Share Your Feedback
Πώς μπορεί να βελτιωθεί το άρθρο;
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.