A script to quickly compress the Magento 2 public folder without the complied files, such as generated, static etc.


If moving you will need to deploy afterwards to regenerate the files we have not compressed and moved.


tar --exclude=./generated/code --exclude=./pub/static --exclude=./generated/metadata --exclude=./var/cache --exclude=./var/composer_home --exclude=./var/page_cache --exclude=./var/view_preprocessed --exclude ./pub/media/catalog/product/cache --exclude ./var/log -zcvf backup-lite.tar.gz .


Excludes the following when backing up


DirectoryDescription
generated/codeContains generated code
generated/metadataContains the compiled dependency injection configuration for all modules.
pub/staticContains js and html files for each store view.
var/cacheAll cacheable objects except the page cache. This directory is empty if you use a third-party cache storage such as Redis.
var/composer_homeHome directory for Setup Wizard artifacts. Do not touch this directory unless you are an experienced developer familiar with the Magento plug-in system.
var/page_cacheCached pages from the full page cache mechanism. This directory is empty if you use a third-party HTTP accelerator such as Varnish.
var/view_preprocessedContains minified templates and compiled LESS (meaning LESS, CSS, and HTML).
pub/media/catalog/product/cacheCached product images
var/logLogging information ie system and exception