While setting up new module and after running php bin/magento setup:upgrade it started to clean cache and file and deleted all front end css and adminhtml css and all visual files. How Can I prevent this happen again as I need to make that module working?

[user@server html]$ php bin/magento setup:upgrade
Cache cleared successfully
File system cleanup:
The directory '/chroot/home/user/rootdir/html/generated/metadata/' doesn't 
exist - skipping cleanup

1 Answer 1


You can use --keep-generated flag like

magento setup:upgrade --keep-generated

It will not remove static files and change only database schema and data if any.

check link for more

  • 1
    What I misunderstood, that I should regenerate static files after doin gthat right? Its not that I want to keep generated, I just want to follow correct procedure which woul dbe to delete all in pub/static, and then regenerate them with setup:static-content:deploy, woul dthat be right procedure?
    – SPL
    Sep 25, 2018 at 6:54
  • If you are in developer mode then you don't need to run deploy command if you have right permissions on files & folders. If you are on production then you don't need to run deploy unless you have changes in static files. --keep-generated flag mainly effective when you are on production mode and you don't want to run static content deploy as it forces some downtime. Let me know if you still have any confusion on this. Sep 25, 2018 at 8:50
  • I understand now, only user kee generated when no impact on static files. Otherwise what is better environmet for module instal production or development?
    – SPL
    Sep 25, 2018 at 12:04
  • Generally what we did is that develop our project on local machine and after that deploy whole code on production server and then put this instance on production mode. If there is need to install a module after this you can use module enable command then run upgrade if it required with --keep-generated as I said earlier it will generate files in generated folder for this module only and won't clear all static files and generated files. Sep 25, 2018 at 12:18

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .