Error when trying to backup a course - Can not create local file pool file

Error when trying to backup a course - Can not create local file pool file

by Paul Staley -
Number of replies: 16


Specific error when backing up:


Error image

For context, I just a jr network administrator that took over moodle. The course I am trying to backup is probably our biggest course, but I don't know the exact size. I feel like the smaller courses have less issues when backing up. The larger ones always fail. Let me know if I need to post any more info. 

The issue shouldn't be storage because there is more than enough available. The issue isn't SQL permissions because small courses can be backed up.

Server details:

  • Windows 10
  • Moodle version 3.8.2+ build 20200428
  • free storage on the VM ~350gb

Error.log : 

[Wed Mar 24 16:32:57.084736 2021] [php7:notice] [pid 3268:tid 1156] [client 192.168.128.83:60578] Default exception handler: Can not create local file pool file, please verify permissions in dataroot and available disk space. Debug: \r\nError code: storedfilecannotcreatefile\n* line 392 of \\lib\\filestorage\\file_system_filedir.php: file_exception thrown\n* line 1794 of \\lib\\filestorage\\file_storage.php: call to file_system_filedir->add_file_from_path()\n* line 1323 of \\lib\\filestorage\\file_storage.php: call to file_storage->add_file_to_pool()\n* line 359 of \\backup\\util\\helper\\backup_helper.class.php: call to file_storage->create_file_from_pathname()\n* line 2062 of \\backup\\moodle2\\backup_stepslib.php: call to backup_helper::store_backup_file()\n* line 34 of \\backup\\util\\plan\\backup_execution_step.class.php: call to backup_store_backup_file->define_execution()\n* line 181 of \\backup\\util\\plan\\base_task.class.php: call to backup_execution_step->execute()\n* line 178 of \\backup\\util\\plan\\base_plan.class.php: call to base_task->execute()\n* line 119 of \\backup\\util\\plan\\backup_plan.class.php: call to base_plan->execute()\n* line 375 of \\backup\\controller\\backup_controller.class.php: call to backup_plan->execute()\n* line 136 of \\backup\\util\\ui\\backup_ui.class.php: call to backup_controller->execute_plan()\n* line 175 of \\backup\\backup.php: call to backup_ui->execute()\n, referer: http://192.168.23.17/moodle/backup/backup.php

[Wed Mar 24 16:32:57.100360 2021] [php7:notice] [pid 3268:tid 1156] [client 192.168.128.83:60578] Potential coding error - existing temptables found when disposing database. Must be dropped!, referer: http://192.168.23.17/moodle/backup/backup.php



Average of ratings: -
In reply to Paul Staley

Re: Error when trying to backup a course - Can not create local file pool file

by Ken Task -
Picture of Particularly helpful Moodlers

Error is pointing to issues with permissions/limitations on the last step in the process of making a backup.

"Can not create local file pool file, please verify permissions in dataroot and available disk space."

'dataroot' is defined in your config.php file for moodle.

Basically, moodle uses moodledata/temp/backup/ and a contenthash named directory consisting of a bunch of letters and numbers.  Using some tool that can browse files, go into moodledata/temp/backup/longdirectoryname and see if there is a file named 'backup.mbz'.  If there is it's the last step in the process of *copying* that backup.mbz file to it's destination as defined in backup defaults.   If backup defaiults are left as is, that area is moodledata/filedir/ a subdirectory xx, and inside xx another subdirectory yy ... filename in Moodle's file system becomes xxyybunchoflettersnumbers (contenthash value in mdl_files table.

Is your PHP a 64 bit version?  In past, on Windows setups, all apps for Moodle were 64 bit except for PHP which was 32bit.   32bit PHP couldn't do large course backups.

Also do check ownerships/permissions on all of moodledata.  Has to be writable by the user under which your web service runs.

Dunno how large a course backup could be?  There is a plugin one could install that attempts to calculate that ... but it shows compat up to 3.7 of Moodle.   May/may not run on your version 3.8.2.

Do you have at least one older backup of this troubled course?  How large was that .mbz file then?

Also, could run a query of the mdl_files table looking for all files that have the extension .mbz that shows contenthash and size (that's calculated).

select filename,filesize,contenthash from mdl_files where filename like '%.mbz';

contenthash will tell you location in moodledata/filedir/

'SoS', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Error when trying to backup a course - Can not create local file pool file

by Paul Staley -
Thanks for the response!
What I've checked:
  • PHP is 64 bit.
  • permissions are also correct. Also, this only seems to be happening on our bigger files, not every backup so I'd assume this is correct anyways.
  • I'm assuming the filesize is bytes so the older backups of the current course(mbz files) are sitting at 3-5 GB. I see the same thing under the contenthash folder.

Note: I've been running manual queries to MySQL for some advanced reporting so I have some experience with it. 

We keep older revisions of the course hidden so users retain badges and competency even after the course is updated so I have other very similar courses and course backups to mess around with.


In reply to Paul Staley

Re: Error when trying to backup a course - Can not create local file pool file

by Ken Task -
Picture of Particularly helpful Moodlers

If you were on Linux, I'd recommend installing MySQL Tuner (a perl script) which looks at performance of DB and stats ... then makes recommendations to tweak config of MySQL.

Do check your web servers error logs/events ... large courses have could have big chunks of data ... over MySQL max_allowed_packets limits.

If you see 'MySQL has gone away' in errors logs, it's max packets.

mysql> show variables like 'max_allowed_packet';

In my.cnf of an 8 Gig memory Linux box, I have had to add:

max_allowed_packet=32M

'SoS', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Error when trying to backup a course - Can not create local file pool file

by Paul Staley -
I tried to adjust that setting and the issue persists. I wish this was on Linux too. I am combing through the logs but I haven't seen much useful information. Do you think adjusting the tmp_table config would help? Does tmp_dir need to be set with something? Currently, the box isn't configured.

I changed the SQL config to give me more logging information, so I will see if that gives me anything else.
In reply to Paul Staley

Re: Error when trying to backup a course - Can not create local file pool file

by Ken Task -
Picture of Particularly helpful Moodlers

tmp_table error would be normal on failed backups ... think MySQL does that auto and what you are seeing is kinda misleading.    Show tables on DB ... see any table names that suggest tmp?

Anyway ... the error is pointing to disk access/space first.

There is a command line only backup.php script in code/admin/cli/ and running it via php-cli with options to save to an alt directory manually created by you.

Takes web service out of the loop.  Errors shown there might provide better hints/clues, me thinks ... dunno really cause I don't use Windows!

Script has help so if you execute: php backup.php with no options help screen should show.

Leon ... you around? smile

'SoS', Ken


In reply to Ken Task

Re: Error when trying to backup a course - Can not create local file pool file

by Paul Staley -
Couldn't find any TMP tables on the SQL server. I was able to run the backup from CLI. The same error as the moodle log file:
Also, I want to restate that there is 200GB available on the server. I backed up a course that's very similar and it ended up being ~4GB.

C:\apache24\htdocs\moodle\admin\cli>php backup.php --courseid=152 --destination=C:\Users\administrator\Desktop\backup
== Performing backup... ==
Default exception handler: Can not create local file pool file, please verify permissions in dataroot and available disk space. Debug:
Error code: storedfilecannotcreatefile
* line 392 of \lib\filestorage\file_system_filedir.php: file_exception thrown
* line 1794 of \lib\filestorage\file_storage.php: call to file_system_filedir->add_file_from_path()
* line 1323 of \lib\filestorage\file_storage.php: call to file_storage->add_file_to_pool()
* line 359 of \backup\util\helper\backup_helper.class.php: call to file_storage->create_file_from_pathname()
* line 2062 of \backup\moodle2\backup_stepslib.php: call to backup_helper::store_backup_file()
* line 34 of \backup\util\plan\backup_execution_step.class.php: call to backup_store_backup_file->define_execution()
* line 181 of \backup\util\plan\base_task.class.php: call to backup_execution_step->execute()
* line 178 of \backup\util\plan\base_plan.class.php: call to base_task->execute()
* line 119 of \backup\util\plan\backup_plan.class.php: call to base_plan->execute()
* line 375 of \backup\controller\backup_controller.class.php: call to backup_plan->execute()
* line 100 of \admin\cli\backup.php: call to backup_controller->execute_plan()

!!! Can not create local file pool file, please verify permissions in dataroot and available disk space. !!!
Potential coding error - existing temptables found when disposing database. Must be dropped!
In reply to Paul Staley

Re: Error when trying to backup a course - Can not create local file pool file

by Ken Task -
Picture of Particularly helpful Moodlers

The backup process uses moodledata/temp/backup/ directory to build an .mbz file according to a 'plan' which is basically parts of a course ... a files.xml is created that maps to the 'files' directory.

So look in your moodledata/temp/backup/ directory for a contenthash type named directory ... long with random letters numbers.

In there should be a .log file.  Check what it says.

Are  there a moodle_backup.xml file as well as a 'backup.mbz' file?

moodle_backup.xml is a road map for the entire backup.  If backup.mbz is there it means backup was successful but moodle could not 'copy' the file to destination and rename it according to backup preferences.

Do the links to files and resources in the course work?

line 1794 of \lib\filestorage\file_storage.php: call to file_system_filedir->add_file_from_path()

select id,userid,filename,filearea,filesize,filepath,component,contenthash from mdl_files

You could set where userid= to the id of the teacher of that course.

Dunno ... just thinking out loud! :|

'SoS', Ken


In reply to Ken Task

Re: Error when trying to backup a course - Can not create local file pool file

by Paul Staley -
Okay, In the temp/backup dir there are many files which all have xml files and a MBZ file. So it looks like the backup is backing up to the temp file correctly. I attempted to take the MBZ file and restore it directly into moodle and ran into the same error. All .log files are blank.

I'm not exactly sure what I'm looking for when running this query: select id,userid,filename,filearea,filesize,filepath,component,contenthash from mdl_files

As far as I know, all the resources in the course function. This is one of the first courses we've tried to back up with a plugin that creates the course in tiles, but we tested backing up other courses that have this plugin without issues.
In reply to Paul Staley

Re: Error when trying to backup a course - Can not create local file pool file

by Ken Task -
Picture of Particularly helpful Moodlers

A .mbz file in that temp build area means it could not be copied to the designated directory set in config - which is what I think your error is related.   No, we don't know why yet! :|

The query was such that you could see if a teacher made a backup file and if it was in teachers private files ... you as admin can't see those backups.

And we're finally getting a detail not mentioned/observed before ... "one of the first courses we're tried to backup with a plugin that creates the course files" ... so what about that plugin?   Have you checked on moodle.org plugins to see if there is any reported issue with backups using that plugin. Is it in need of updating?   That plugin 'creates course files' ... never heard of a plugin that does that.

What can I say ... not all moodles are used the same ... not all hosting set ups are the same ... not all courses are the same ... not all backups of courses with plugins are the same ... ??????

At least we might be getting closer to the solution! :|

'SoS', Ken


In reply to Ken Task

Re: Error when trying to backup a course - Can not create local file pool file

by Paul Staley -
Let me explain further about the plugin:

  • We have successfully backed up other courses that use the plugin, but not this large.
  • I switched the course back to "topics" format and tried to back it up without success
  • I changed another similar course to "tiles" and exported without issues.
  • Nothing on the plugin's bug page mentions anything similar to mine.
  • We can uninstall/disable the plugin on the test env plan below. 

I am exporting the VM to an external drive so I can possibly do more aggressive testing without breaking the main site. Maybe update apache,php, or moodle? Not sure if any of this would help.

will any of the temp/backup XML info tell us anything useful? Nothing pops out to me.

More info about the course that's failing:

  • Contains about 1.5hrs of various videos (i don't believe these are stored in the course backup because the .mbz it's so small)
  • In a sense, the course is a copy of a copy of a copy. Meaning, every few months we release a new revision. The old revision is backed up and restored with a new revision number, then tweaked/released. I hope this makes sense. 
  • This probably has double the amount of videos than the last revision. 
  • Most automated backups are disabled because the server is backed up every day to the cloud. 

If I think of anything else I will add to this. 


In reply to Paul Staley

Re: Error when trying to backup a course - Can not create local file pool file

by Ken Task -
Picture of Particularly helpful Moodlers

What is the name of this plugin?  Can one find it in Moodle plugins for downloading and installing?   Pages for plugins sometimes ask those using the report issues and maybe get answers on their resource pages (git repo?).

If the temp directory has a moodle_backup.xml (which is road map for the course backup) and a file named backup.mbz it finished backing up ... it fails when trying to copy ... repeat copy ... repeat copy ... to destination ... and says cannot create local pool file ... am assuming (don't use Windows, remember!) that means it could not copy the backup.mbz to destination directory - which is what?

Cloning to another VM to work on it is a good idea ... but if you upgrade apache/php/mysql/or version of Moodle, then you've changed environment so you are not then comparing apples to apples.   But ... if you do all that and the issue goes away ... might be a piece of the puzzle ... the new VM won't be using the same file system/Windows 7 environment.

If it gets fixed doing all that, then there is your fix for production site - me thinks. smile

Before you do, please dig into what you might find following:

https://www.google.com/search?client=firefox-b-1-d&q=windows+7+cannot+create+local+pool+file

It really could be a Windows issue.

'SoS', Ken

In reply to Ken Task

Re: Error when trying to backup a course - Can not create local file pool file

by Paul Staley -
here's the tiles link: https://moodle.org/plugins/format_tiles
I didn't see anything on their bug reporting site that was similar enough to look into.

Wouldn't the backup.mbz get copied to a place in the database under filedir directory? That was my thinking, but I'm not sure.

Here what I've been working on:
  • Completely uninstalled the "tiles" format from the test environment and tested a backup without success
  • Uninstalled other addon plugins to test if it was any of them
  • Tried various other changes without success.

Here is what I've made progress with:

When backing up, I was able to trial and error which lesson to not include in the backup for the backup to work. So, if I uncheck the largest lesson in the course, and the backup completes successfully at a size of 2.5 ish GB. I believe the error is related to this one lesson that has a lot of videos in it. I'm not exactly sure what the end solution is. At least I don't have to recreate the entire course now.


Do you think the size is too large? The server has 8GB of ram, is this enough?

Any Ideas?

Thanks,

In reply to Paul Staley

Re: Error when trying to backup a course - Can not create local file pool file

by Ken Task -
Picture of Particularly helpful Moodlers

"Wouldn't the backup.mbz get copied to a place in the database under filedir directory?"

The backup.mbz file is a file and it is *copied* from moodledata/temp/backup/somelonglettersnumbersdir/ to the location you choose in backup defaults.  IF you leave backup preferences at defaults, the backup.mbz file is *copied* from moodledata/temp/backup/somelonglettersnumbersdir/ to moodledata/filedir/XX/YY/XXYYbunchofletersnumbers as a file.  Note it's now not humanly recognizable ... does not have filename.mbz.

The mdl_files table has a row added that provides information about that .mbz file.   One column of that table, contenthash, is the location and filename in /moodledata/filedir/

Through your trial an error on selecting content in that course has pinpointed the troubled resource.   You say if you backup that course excluding X then it works.    So, make one more backup and this time the only item that's to be included in the backup is the one item you excluded in the first backup that worked - no users - no quizzes - no events - no logs ... just that one item.   You will then get an idea of how large that one item is.

"Do you think the size is too large?"

Evidently too many resources - large files contained therein.

"...8GB of ram"

Should be ... have had an 8GB RAM server that had course backups over 50Gigs.

The error is cannot create file pool .. don't think that has to do with RAM but space.

Let's also remember you are using Windows and a version (Windows 10) which isn't server software, is it?

'SoS', Ken

In reply to Paul Staley

Re: Error when trying to backup a course - Can not create local file pool file

by Ken Task -
Picture of Particularly helpful Moodlers

In the rirst posting of this thread:

You gave Server details

Server details as:
    Windows 10
    Moodle version 3.8.2+ build 20200428
    free storage on the VM ~350gb

and in same posting an error.log clip which showed

Default exception handler: Can not create local file pool file, please verify permissions in dataroot and available disk space

The url to your server or referrer in same posting said:
http://192.168.23.17/moodle/backup/backup.php

Please share the dataroot line in your config.php file.

The one that has: $CFG->dataroot  =

BTW, where you tried to save the command line backup you attempted showed attempting to save to the administrators account Desktop.

Now am not a Windows person (not for many years now) but an application saving something to Administorators Desktop would scare me ... maybe Windows 10 doesn't like that!!!

Since moodledata/filedir/ should have ownerships/permissions where moodle can store files, what if you did the command line backup again, only this time save to C:\pathtomoodledata\filedir\   .... yes, one should not use the cli script that way and nothing but moodle code executing should save to filedir.   Just a test to see if php backup script can write to that subdirectory and if it still kicks out the same error.

Guess we are gonna have to wait for a true Windows guru to contribute cause am out of ideas and suggestions (non of which has been Windows specific so sorry bout that).

'SoS', Ken




In reply to Ken Task

Re: Error when trying to backup a course - Can not create local file pool file

by Paul Staley -
I've tried many things without luck. I attempted to save to many other locations on the machine. Even to the public user account directories.

$CFG->dataroot = 'C:\\Apache24\moodledata';

The crazy part to me is that if I take the mbz from the temp folder and try to restore it in moodle, it fails out with the same error. There's something stopping larger files from being moved to the filedir. This file is still the biggest course and it looks to sit at around 12GB (more than I originally thought).

I'm kinda running out of ideas as well. I've been trying various things. Tried saving to many different locations. I even changed ownership of the folders and what account the services start as without success.

How hard do you think it would be to migrate to linux?

I appreciate your help so far. I just wish we could fix this sad
In reply to Paul Staley

Re: Error when trying to backup a course - Can not create local file pool file

by Paul Staley -
I never found a solution to this issue. I migrated our moodle to an ubuntu cloud-hosted machine and the backup started working properly after the migration. I'm not sure what could cause this, but it seems to be something with windows or the windows versions of mysql, myphpadmin, or apache.
Average of ratings: Useful (1)