Backup create empty entry (filename=".") in mdl_files table

Backup create empty entry (filename=".") in mdl_files table

by Nicolas Dalpe -
Number of replies: 3

Hi everyone,

I noticed that when I create a course backup Moodle seems to populate the files table with the backup record (xyz.mbz) and another empty record with filename set to "." - see picture below. Those "." files are created on the disk but are empty.

Does anyone know why Moodle create those empty files? Can I delete them?

Thank you in advance for your help

Moodle 3.8.1+ (Build: 20200214)
CenOS 7.5
PHP 7.4.3
MySQL  Ver 15.1 Distrib 10.1.41-MariaDB

screenshot of the files database table whowing the dot file entries


Terminal window showing that the dot files on the disk are actually empty files

Average of ratings: -
In reply to Nicolas Dalpe

Re: Backup create empty entry (filename=".") in mdl_files table

by Ken Task -
Picture of Particularly helpful Moodlers

How often is your cron job (and thus task that clean up areas of files in moodle) running?

Leave DB alone ... note some references are to recyclebin for deletion of a course category + courses contained therein if you choose that option.   The . records kinda like from OS and ls ./.

The file -b for the contenthash ... in your table shared didn't see if that contenthash matched up with anything   a . row or one of the .mbz files in moodledata/filedir/

Even if moodle were creating 0 byte files, no space is taken up and counts only vs inod limits of server.

Suggest running cron ... several times from cli until it shows it did nothing ... all caught up ... and then use the file -b command again to see if 0 byte file gone.

'SoS', Ken


In reply to Ken Task

Re: Backup create empty entry (filename=".") in mdl_files table

by Nicolas Dalpe -
Hi Ken,
Thx for your answer.

How often is your cron job (and thus task that clean up areas of files in moodle) running?
Crontab setting: * * * * * php /var/www/html/admin/cli/cron.php > /dev/null

My settings:
tool_recyclebin | coursebinexpiry : 1 minute
tool_recyclebin | categorybinexpiry : 1 minute

Leave DB alone...
Don't worry I only use the database as "read only". I never modify the database directly but I use it to understand how Moodle works.


The . records kinda like from OS and ls ./.
Yeah, I don't know why Moodle want to keep that record... but as usual, not understanding a feature doesn't mean there is no reason behind it... I will have to read the code to understand more about the File Storage API.


The file -b for the contenthash... in your table shared didn't see if that contenthash matched up with anything a . row or one of the .mbz files in moodledata/filedir/
Yes, it did point to a . filename. It seems


Suggest running cron ... several times from cli until it shows it did nothing ... all caught up ... and then use the file -b command again to see if 0 byte file gone.
Cron running successfully


I was just wondering about those because there are more than 2000 . entry in my database and non of them are scheduled for deletion. I'll take a deep dive into the file API code and find out why... when I have time... one day maybe...


Thank you


In reply to Nicolas Dalpe

Re: Backup create empty entry (filename=".") in mdl_files table

by Ken Task -
Picture of Particularly helpful Moodlers

The .'s I think are related to operating system ... like ./ means present working directory and ../ means up one level.

You've shown how often your cron job runs ... once every minute good and is
the recommended setting.
But it's running as user vagrant.  Heard it's best to run it as the user under which
the web service runs (www-data/apache/apache2).
How about scheduled task in that cron job.
Task don't run once every minute but have a schedule of their own.

/admin/tool/task/scheduledtasks.php

Clean backup tables and logs \core\task\backup_cleanup_task
Cleanup files in trash \core\task\file_trash_cleanup_task
Cleanup category recycle bin \tool_recyclebin\task\cleanup_category_bin
Cleanup course recycle bin \tool_recyclebin\task\cleanup_course_bin
Delete stale temp files \core\task\file_temp_cleanup_task
Cleanup files in trash \core\task\file_trash_cleanup_task

There's a 'run now' button under any of those to test individually outside of the overall cron run?

BTW, what's shown above can also be run via command line:

/admin/tool/task/cli/schedule_task.php with the task to run ...

I have a little bash shell script in that directory that I can run:

./docleanup

executes the following one at a time.

php schedule_task.php --execute="\core\task\session_cleanup_task"
php schedule_task.php --execute="\core\task\file_temp_cleanup_task"
php schedule_task.php --execute="\core\task\file_trash_cleanup_task"
php schedule_task.php --execute="\tool_recyclebin\task\cleanup_category_bin"
php schedule_task.php --execute="\tool_recyclebin\task\cleanup_course_bin"
php schedule_task.php --execute="\core\task\cache_cleanup_task"
php schedule_task.php --execute="\core\task\cache_cron_task"
php schedule_task.php --execute=\\core\\task\\cache_cron_task

'SoS', Ken