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

(Дмитрий Федюк) #1

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

find . -name "*--*" -type d -exec rm -rf {} \;
find . -name "*-BKP" -type f -delete
find . -name "*-disable" -type f -delete
find . -name "*-ORG" -type f -delete
find . -name "*.*-" -type f -delete
find . -name "*.*--*" -type f -delete
find . -name "*.*_" -type f -delete
find . -name "*.bak" -type f -delete
find . -name "*.bak.*" -type f -delete
find . -name "*.bkp" -type f -delete
find . -name "*.MODIFIED" -type f -delete
find . -name "*.old" -type f -delete
find . -name "*.orig" -type f -delete
find . -name "*.ORIGINAL" -type f -delete
find . -name "*.original" -type f -delete
find . -name "*.original.*" -type f -delete
find . -name "*.phtml?*" -type f -delete
find . -name "*.save" -type f -delete
find . -name "*=BKP" -type f -delete
find . -name "*_backup.*" -type f -delete
find . -name "*_bak.*" -type f -delete
find . -name "*_new" -type f -delete
find . -name "*_orig" -type f -delete
find . -name "*_ORIG*" -type f -delete
find . -name "*_original" -type f -delete
find . -name "*_prev" -type f -delete
find . -name "*_prev.css" -type f -delete
find . -name ".DS_Store" -type f -delete
find . -name "error_log" -type f -delete
find . -name __MACOSX -exec rm -rf {} \;
find app vendor -name "?*.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 \
	-zcvf ~/${PWD##*/}-$(date '+%Y-%m-%d-%H-%M').tgz . \
	--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/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

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

tar \
	-zcvf ~/${PWD##*/}-$(date '+%Y-%m-%d-%H-%M').tgz . \
	--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/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

Для Magento 1

tar \
	-zcvf ../${PWD##*/}-$(date '+%Y-%m-%d-%H-%M').tgz . \
	--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'

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

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

Часто используемая мной информация в едином месте