I have not found too much information on an efficient process for a rolling development of my site so I can add custom modules and other file changes on staging and then push those changes onto the live copy of my site with magento2.

In Magento 1.9 we just had a git clone of the files and git pulled all changes that were ready for the live site this obviously will not work in magento2 were my staging site is in developer mode and my live site is in production.

What is the best practice that involves the least live site downtime ? (no downtime would be optimal if that is possible)

  • 1
    did you find an answer, we're still trying to figure this one out
    – Haim
    Feb 6, 2017 at 14:53

1 Answer 1


You can use ansible to automate the steps :

From a global point of view :

(Manage all your changes with setup/upgrade scripts)

  • backup database
  • toggle maintenance
  • disable crons
  • retrieve updated code source
  • set your shared folders
  • install composer dependencies
  • execute bin/magento setup:install with parameters
  • update magento env configuration for Redis / Varnish and ElasticSearch
  • upgrade with ./bin/magento setup:upgrade
  • build di with ./bin/magento setup:di:compile -vvv
  • flush cache ./bin/magento cache:clean
  • set magento mode ./bin/magento deploy:mode:set {{ m2site_mode }}
  • reindex ./bin/magento indexer:reindex
  • configure / enable crons

Adapt these steps with your needs.

The clue is to make to steps works for new environement or for existent environement.

You will have downtime if you have some setup script to execute. To minimize downtime, do these steps on a preproduction server, and copy all generated code to your production server. You can reindex data in background.

  • after copying all generated code to production for example, what would be the necessary steps ? just bin/magento setup:upgrade ?
    – medmek
    Jun 21, 2020 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.