I'm using Magento 2.4 and my installation is using 200GB, I'd like to reduce it.

I want to remove old logs, backups, caches, duplicated images and etc.

How could I optimize it?


All the ones you mention are worth being looked at. I may have some more for you to take a look:

in pub folder, it is useful to remove files that are not meant to be there and pub is often misused.

  1. Right away, find files that are larger than 5M is good place to start. They may be legitimate files. However, by doing just this, I once found an image that was a malware at the time.

this command will list these big files for you (this command assumes you are in a terminal at the pub folder of your magento site)

find . -type f -size +5M 
  1. Find the images for which products have been deleted. There are scripts out there performing query for doing this search but I have not used any since Magento 2 came

  2. find images that are quite big and may not be needed:

    find . -name "*png" -type f -size +2M

    find . -name "*jpg" -type f -size +2M

  3. files that may have been created during development. I doubt it is your case but possibly worth a try:

find . -name "*sql" -type f

find . -name "*zip" -type f

find . -name "*gz" -type f

  1. although it is less common, this same practice can apply to vendor folder and app folder. As you know, these folders do contain the modules for your site. I have come across modules creating export files and these could amount to large amount of space. The command below would list the possible files

    find . -name "*csv" -type f

  • Also var/ folder. Arcive old logs. Remove old import/export logs – orthener Jul 9 '20 at 19:16
  • Definitely, I have just listed the possibility that Rafael has not listed. Var/session for instance can be massive if not cleared by the os, thanktfor your comment – Herve Tribouilloy Jul 9 '20 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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