Как заархивировать сайт на Magento 2 с командной строки?

Удаляем мусор

find . -iname "*--*" -type d -exec rm -rf {} \;
find . -iname "*-bkp" -type f -delete
find . -iname "*-bkp.*" -type f -delete
find . -iname "*-disable" -type f -delete
find . -iname "*-org" -type f -delete
find . -iname "*.*-" -type f -delete
find . -iname "*.*--*" -type f -delete
find . -iname "*.*_" -type f -delete
find . -iname "*.*bak" -type f -delete
find . -iname "*.bak" -type f -delete
find . -iname "*.bak.*" -type f -delete
find . -iname "*.bkp" -type f -delete
find . -iname "*.css-*" -type f -delete
find . -iname "*.gif-*" -type f -delete
find . -iname "*.ico-*" -type f -delete
find . -iname "*.jpg-*" -type f -delete
find . -iname "*.js-*" -type f -delete
find . -iname "*.js_*" -type f -delete
find . -iname "*.modified" -type f -delete
find . -iname "*.old" -type f -delete
find . -iname "*.old.*" -type f -delete
find . -iname "*.orig" -type f -delete
find . -iname "*.original" -type f -delete
find . -iname "*.original.*" -type f -delete
find . -iname "*.php-*" -type f -delete
find . -iname "*.phtml-" -type f -delete
find . -iname "*.phtml-*" -type f -delete
find . -iname "*.phtml?*" -type f -delete
find . -iname "*.png-*" -type f -delete
find . -iname "*.save" -type f -delete
find . -iname "*.swf-*" -type f -delete
find . -iname "*.test" -type f -delete
find . -iname "*.txt-*" -type f -delete
find . -iname "*.xml-" -type f -delete
find . -iname "*.xml-*" -type f -delete
find . -iname "*.xml.before" -type f -delete
find . -iname "*.xml_*" -type f -delete
find . -iname "*=bkp" -type f -delete
find . -iname "*_backup.*" -type f -delete
find . -iname "*_bak.*" -type f -delete
find . -iname "*_new" -type f -delete
find . -iname "*_orig*" -type f -delete
find . -iname "*_original" -type f -delete
find . -iname "*_prev" -type f -delete
find . -iname "*_prev.css" -type f -delete
find . -iname ".DS_Store" -type f -delete
find . -iname "error_log" -type f -delete
find . -iname "Thumbs.db" -type f -delete
find . -iname "vssver2.scc" -type f -delete
find . -iname __MACOSX -exec rm -rf {} \;
find app vendor -iname "?*.php*_*" -type f -delete
rm -rf ./app/app
rm -rf ./generated_
bin/magento cache:clean

df.tips/t/858
df.tips/t/859

Поиск мусора и тяжёлых папок

du -csh ./* | sort -h -r 
find . -name "*.zip" -type f
find . -name "*.tgz" -type f
find . -name "*.tar.gz" -type f
find . -name "*.gz" -type f
find . -name "*.sql" -type f

Все файлы

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

Без ненужных для разработки папок

tar \
	--exclude='*.gz' \
	--exclude='*.mov' \
	--exclude='*.mp4' \
	--exclude='*.pdf' \
	--exclude='*.tgz' \
	--exclude='*.zip' \
	--exclude='./.easyssl_backup' \
	--exclude='./.git' \
	--exclude='./.github' \
	--exclude='./.sucuriquarantine' \
	--exclude='./.well-known' \
	--exclude='./__MACOSX' \
	--exclude='./adminer.php' \
	--exclude='./blog' \
	--exclude='./cgi-bin' \
	--exclude='./dev' \
	--exclude='./dist' \
	--exclude='./generated' \
	--exclude='./magmi' \
	--exclude='./node_modules' \
	--exclude='./ow_scripts' \
	--exclude='./pub/images' \
	--exclude='./pub/media/amasty/amoptimizer_dump' \
	--exclude='./pub/media/amasty/amoptmobile' \
	--exclude='./pub/media/amasty/amopttablet' \
	--exclude='./pub/media/amasty/webp' \
	--exclude='./pub/media/cache' \
	--exclude='./pub/media/captcha' \
	--exclude='./pub/media/catalog/product/cache' \
	--exclude='./pub/media/descriptions' \
	--exclude='./pub/media/helpdesk/attachments' \
	--exclude='./pub/media/import' \
	--exclude='./pub/media/importexport' \
	--exclude='./pub/media/ipattachments' \
	--exclude='./pub/media/magefan_blog' \
	--exclude='./pub/media/megnor_blog' \
	--exclude='./pub/media/product/cache' \
	--exclude='./pub/media/tmp/catalog/product' \
	--exclude='./pub/static/*' \
	--exclude='./pub/ub-tool' \
	--exclude='./pub/wp' \
	--exclude='./sucuri-backups' \
	--exclude='./test' \
	--exclude='./tmp' \
	--exclude='./var' \
	--exclude='./vendor/magento/magento2-base' \
	--exclude='./vendor/magento/sample-data-media/catalog/product' \
	--exclude='./wp' \
	--exclude='sitemap*.xml' \
	./pub/media/import/.htaccess \
	./pub/static/.htaccess \
	./var/composer_home/.htaccess \
	./var/composer_home/auth.json \
	./var/composer_home/packages.json \
	-zcvf ~/${PWD##*/}-$(date '+%Y-%m-%d-%H-%M').tgz .

Без товарных картинок и ненужных для разработки папок

tar \
	--exclude='*.gz' \
	--exclude='*.mov' \
	--exclude='*.mp4' \
	--exclude='*.pdf' \
	--exclude='*.tgz' \
	--exclude='*.zip' \
	--exclude='./.easyssl_backup' \
	--exclude='./.git' \
	--exclude='./.github' \
	--exclude='./.sucuriquarantine' \
	--exclude='./.well-known' \
	--exclude='./__MACOSX' \
	--exclude='./adminer.php' \
	--exclude='./blog' \
	--exclude='./cgi-bin' \
	--exclude='./dev' \
	--exclude='./dist' \
	--exclude='./generated' \
	--exclude='./magmi' \
	--exclude='./node_modules' \
	--exclude='./ow_scripts' \
	--exclude='./pub/images' \
	--exclude='./pub/media/amasty/amoptimizer_dump' \
	--exclude='./pub/media/amasty/amoptmobile' \
	--exclude='./pub/media/amasty/amopttablet' \
	--exclude='./pub/media/amasty/webp' \
	--exclude='./pub/media/cache' \
	--exclude='./pub/media/captcha' \
	--exclude='./pub/media/catalog/product' \
	--exclude='./pub/media/descriptions' \
	--exclude='./pub/media/helpdesk/attachments' \
	--exclude='./pub/media/import' \
	--exclude='./pub/media/importexport' \
	--exclude='./pub/media/ipattachments' \
	--exclude='./pub/media/magefan_blog' \
	--exclude='./pub/media/megnor_blog' \
	--exclude='./pub/media/product' \
	--exclude='./pub/media/tmp/catalog/product' \
	--exclude='./pub/static/*' \
	--exclude='./pub/ub-tool' \
	--exclude='./pub/wp' \
	--exclude='./sucuri-backups' \
	--exclude='./test' \
	--exclude='./tmp' \
	--exclude='./var' \
	--exclude='./vendor/magento/magento2-base' \
	--exclude='./vendor/magento/sample-data-media/catalog/product' \
	--exclude='./wp' \
	--exclude='sitemap*.xml' \
	./pub/media/import/.htaccess \
	./pub/static/.htaccess \
	./var/composer_home/.htaccess \
	./var/composer_home/auth.json \
	./var/composer_home/packages.json \
	-zcvf ~/${PWD##*/}-$(date '+%Y-%m-%d-%H-%M').tgz .

Для Magento 1

tar \
	--exclude='*.gz' \
	--exclude='*.mov' \
	--exclude='*.mp4' \
	--exclude='*.pdf' \
	--exclude='*.tgz' \
	--exclude='*.zip' \
	--exclude='./.cache' \
	--exclude='./.easyssl_backup' \
	--exclude='./.git' \
	--exclude='./.github' \
	--exclude='./.sucuriquarantine' \
	--exclude='./.well-known' \
	--exclude='./__MACOSX' \
	--exclude='./adminer.php' \
	--exclude='./cgi-bin' \
	--exclude='./dev' \
	--exclude='./dist' \
	--exclude='./includes/src' \
	--exclude='./magmi' \
	--exclude='./media/catalog/product/cache' \
	--exclude='./media/css_secure' \
	--exclude='./media/js' \
	--exclude='./media/tmp' \
	--exclude='./media/upslabelinv' \
	--exclude='./ow_scripts' \
	--exclude='./sucuri-backups' \
	--exclude='./test' \
	--exclude='./tmp' \
	--exclude='./var' \
	--exclude='./wp' \
	-zcvf ../${PWD##*/}-$(date '+%Y-%m-%d-%H-%M').tgz .

Только картинки для Magento 1 (находясь в папке media)

tar \
	--exclude='*.gz' \
	--exclude='*.mov' \
	--exclude='*.mp4' \
	--exclude='*.pdf' \
	--exclude='*.tgz' \
	--exclude='*.zip' \
	--exclude='./catalog/product/cache' \
	--exclude='./css_secure' \
	--exclude='./js' \
	--exclude='./tmp' \
	--exclude='./upslabelinv' \
	-zcvf ~/${PWD##*/}-$(date '+%Y-%m-%d-%H-%M').tgz .

Упаковка товарных картинок в многотомный архив RAR

cd pub/media/catalog
rar a -v500000k product.rar product -xproduct/cache