How to archive a Magento 2 site from the command line?

All files

tar -zcvf ../${PWD##*/}-$(date '+%Y-%m-%d-%H-%M').tgz .

Without «var», «.git», and «dev» folders

tar --exclude='./var' --exclude='./.git' --exclude='./dev' -zcvf ../${PWD##*/}-$(date '+%Y-%m-%d-%H-%M').tgz .

Without «var», «.git», «dev» folders, and without product images

tar --exclude='./var' --exclude='./.git' --exclude='./dev' --exclude='./pub/media/catalog/product' -zcvf ../${PWD##*/}-$(date '+%Y-%m-%d-%H-%M').tgz .