MySQLServer has gone away .... too much data in a chunk.
max_allowed_packet needs to be increased in my.cnf config for DB server.
Query:
mysql> show variables like 'max_allowed_packet';
https://dev.mysql.com/doc/refman/5.7/en/program-variables.html
Think default is 8M (I think) ... wouldn't hurt for your server to set to 16M - higher if you continue to get 'gone away'.
trashdir ... you can manually remove contents ... no adverse affects
Delete stale temp files (core\task\file_temp_cleanup_task)
Whats in moodledata/temp/backup/
Successful backups leave 0 byte log files.
Any .log file larger than 0 bytes indicates a failed backup for some reason.
Unfortunately, the .log files aren't really that helpful in discovering why
as they show only at what point in the 'plan' (a number) it failed.
** But, if there are a bunch of directories by hash names, those are what moodle was using to build a backup file.
Some could actually have 'backup.mbz' files in them ... which means the backup was success but the process failed at the last step - copying the .mbz file to destination.
Anyhoo ... everything in moodledata/temp/backup/ could be manually removed.
Suggest it's time for you to install and run MySQLTuner. Will help with DB server config.
https://github.com/major/MySQLTuner-perl
For info about Tuner ...
https://www.linode.com/docs/databases/mysql/how-to-optimize-mysql-performance-using-mysqltuner/
There are also some command line only scripts in moodlecode/admin/cli/ that help with DB for Moodle ... all begin with mysql_ and all have 'help' screens as defaults when called via php mysql_scriptname.php
'SoS', Ken