I often have to create a quick copy of a Magento 2 site to store on my local machine for development. Typically I only need the core files, extensions, themes, etc. Skipping the folders in the Magento 2 filesystem that aren’t needed for development will save a lot of disk space.
The command below quickly creates a tar.gz backup of a root Magento 2 directory, skipping folders that aren’t relevant for local storage. Via SSH, navigate to the directory containing your root Magento 2 folder and enter:
tar -zcvf html.tar.gz /path/to/html --exclude=html/generated --exclude=html/media --exclude=html/pub --exclude=html/var