How could I zip all my Magento files excluding non-required to a local setup?

I usually run this command to get all the files. But, it takes too long and the files are too heavy.

zip -r magento2.zip ./*

Do you have any suggestions to improve it?

2 Answers 2


To create compressed archive named data.zip of data folder in the current directory, run: zip -r data.zip data/


You can exclude the non-versioned folders and you can use -9 to compress all the files included in your ZIP.

zip -r -9 magento2.zip ./* \
-x "vendor/*" \
-x "generated/*" \
-x "pub/static/*" \
-x "pub/media/*" \
-x "var/*" \
-x "pub/wp/wp-content/uploads/*" \
-x "node_modules/*"

To compress your media folder too, I recommend using:

n98-magerun.phar media:dump media.zip

Generated CSS, JS and product image cache you can pass the option --strip

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.