We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more.
Magento 2 - clean up files before backup
It might be a good idea to decrease Magento size on disk and the number of files before doing a backup. This way your backups will be smaller and faster and the restore will take less time. Using a command: ( from Magento 2 root directory )
du -a . | sort -n -r | head -n 20
Will show which files / directories take up most
In our case it was
/pub and /var
So repeating the command
du -a var | sort -n -r | head -n 20
Will show what directories take space inside the var directory.
In our case we had a lot of imports and exports and some cache and logs:
pub/media/catalog/product/cache
var/log/cron.log
You can repeat the above for the /pub directory
du -a pub | sort -n -r | head -n 20
Next thing to do would be to delete some unused images - You can see our post on how to do that:
It is a good idea to setup cron job to clean up the cron.log inside Magento root/var/log ( We will soon add more information about that )