Preventing Moodle to periodically delete backup directory?

Preventing Moodle to periodically delete backup directory?

oleh Nicolas Martignoni -
Jumlah balasan: 12
Gambar dari Core developers Gambar dari Documentation writers Gambar dari Particularly helpful Moodlers Gambar dari Plugin developers Gambar dari Testers Gambar dari Translators
Background

To provide the MoodleBox image (free as in speech!, see https://moodlebox.net/ and https://github.com/martignoni/moodlebox), I install Moodle on a Raspberry Pi 3. Main reasons for such a tiny server are: hardware price, mobility and access to a Moodle site when no Internet available. MoodleBox is widely used in Africa, South and North-America and in Europe.

For performance reasons, I moved the moodledata/temp on a RAM filesystem (tmpfs). But RPi RAM size is modest (1GB) and I need to keep moodledata/temp (typically around 50 MB). This small size is generally not a problem for the temp directory contents, except for backup files, which are written to moodledata/temp/backup (during backup/restore) and can be very big (typically more than 100 MB).

My solution to this is currently to soft-link the moodledata/temp/backup directory outside of moodledata/temp, e.g. to moodledata/backup (mkdir -p moodledata/backup; ln -s moodledata/backup moodledata/temp/backup), and then to install Moodle.

This seems to work. However, occasionally, the backup directory is deleted by Moodle, and this deletion breaks (evidently) the backup/restore process, since Moodle can't find moodledata/temp/backup, can't create it either (since we've a link in this place), and drops an error ("error/cannot_create_backup_temp_dir").

Questions

  1. Where (in the code) and when (and why) is Moodle deleting the moodledata/temp/backup directory? I looked everywhere in the code, without finding it. I can't figure out in which circumstances this occurs. I even tried every scheduled tasks without finding it.
  2. As a workaround, do you know any way to prevent Moodle to periodically delete the moodledata/temp/backup directory? I tried to change the umask and user and group permissions, but this didn't work.
  3. As another workaround, I think of re-creating periodically the moodledata/backup directory (via cron). Any thoughts about such a solution?
  4. Wouldn't it be a good idea for Moodle to have the possibility to store the backup files (sometimes very big!) outside of moodledata/temp, in a specific location in moodledata (or elsewhere), enabling more flexibility for the sysadmin? This could be a config.php setting, just like CFG->tempdir or $CFG->cachedir.

Any help and/or hint would be greatly appreciated.

Nicolas

Rata-rata penilaian:Useful (1)
Sebagai balasan Nicolas Martignoni

Re: Preventing Moodle to periodically delete backup directory?

oleh Tobias Reischmann -

Hey Nicolas,

the responsible task should be '\core\task\file_temp_cleanup_task'. This process periodically goes through all temp directories and checks their change date.

Another workaround, which comes to my mind, is to simple do not give your webserver user write permission to the backup temp dir. Looking at the code of the cleanup task, this should result in an error log. However, your link should remain were it is.

Cheers,

Tobias

Rata-rata penilaian:Useful (2)
Sebagai balasan Tobias Reischmann

Re: Preventing Moodle to periodically delete backup directory?

oleh Nicolas Martignoni -
Gambar dari Core developers Gambar dari Documentation writers Gambar dari Particularly helpful Moodlers Gambar dari Plugin developers Gambar dari Testers Gambar dari Translators

Thanks Tobias, I'll look into this.

Edit: I can reproduce the deletion now. But, even when the web server has no write permission, the backup dir is deleted. Have to dig deeper. senyum

Sebagai balasan Tobias Reischmann

Re: Preventing Moodle to periodically delete backup directory?

oleh sam marshall -
Gambar dari Core developers Gambar dari Peer reviewers Gambar dari Plugin developers
Hi Nicholas,

Based on Tobias's information, I suggest you create a cron job that simply touches the directory / a file in the directory once per day. The default tempdatafoldercleanup is apparently a week so that should prevent it from ever deleting it? Rather than recreating it after deleted, this seems safer. (If you can't get the permissions to work!)

--sam

Rata-rata penilaian:Useful (3)
Sebagai balasan sam marshall

Re: Preventing Moodle to periodically delete backup directory?

oleh Nicolas Martignoni -
Gambar dari Core developers Gambar dari Documentation writers Gambar dari Particularly helpful Moodlers Gambar dari Plugin developers Gambar dari Testers Gambar dari Translators

Sam and Tobias, you made my day senyum

Sam's workaround works a treat. I'll adjust the cron down to once per hour, in case when the admin changes the setting "tempdatafoldercleanup" to its lower limit berkedip

Ciao!

Nicolas

Sebagai balasan Nicolas Martignoni

Re: Preventing Moodle to periodically delete backup directory?

oleh AL Rachels -
Gambar dari Core developers Gambar dari Particularly helpful Moodlers Gambar dari Plugin developers Gambar dari Testers

Hi Nicolas,

Just a thought, if the memory on your Raspberry Pi 3 is a problem, you might want to try an Odroid-XU4 or Odroid-HC1. They both have 2GB of LPDDR3 RAM. Their 8 core CPU's and 2 GHz speed is a very noticeable improvement over the PI 3's. Price is very reasonable for either one.

If your server needs to have a monitor, the XU4 has HDMI. The HC1 is cheaper, no monitor connection, no moving parts, and a SATA connector for 2.5inch HHD/SSD. I currently have one that uses a 64GB MicroSDC for the Ubuntu 16.04 OS and a 500GB SSD for extra storage. (Videos from Red5-still working on getting this the way I want it.) Supposedly, Hardkernal is going to release a version that can accommodate 3.5inch drives.

Sebagai balasan AL Rachels

Re: Preventing Moodle to periodically delete backup directory?

oleh Nicolas Martignoni -
Gambar dari Core developers Gambar dari Documentation writers Gambar dari Particularly helpful Moodlers Gambar dari Plugin developers Gambar dari Testers Gambar dari Translators

Hi Daniel,

Thanks for you input. I've already thought of RPi alternatives like the Odroid or OrangePi, but I'll stick with the Raspberry, since it's much cheaper than other similar hardware (though less powerful). For the audience of the MoodleBox, the price seems to be an important factor. The RPi is very well supported too, which simplifies the support.

As a matter of fact, memory (and speed) is not so much a problem, but I want to avoid to drain too much of it with a too big RAM partition. This is the reason to avoid backup files in the temp directory.

Anyway thanks again for your thoughts.

Nicolas

Sebagai balasan Nicolas Martignoni

Re: Preventing Moodle to periodically delete backup directory?

oleh Séverin Terrier -
Gambar dari Documentation writers Gambar dari Particularly helpful Moodlers Gambar dari Testers Gambar dari Translators

Hi,

Glad to see you've found a solution for the MoodleBox senyum

But i still think that being able to define in config.php something like $CFG->backuptempdir would be useful.

Perhaps it needs a tracker issue?

Séverin

Sebagai balasan Séverin Terrier

Re: Preventing Moodle to periodically delete backup directory?

oleh Nicolas Martignoni -
Gambar dari Core developers Gambar dari Documentation writers Gambar dari Particularly helpful Moodlers Gambar dari Plugin developers Gambar dari Testers Gambar dari Translators

I find in too a good idea. But has it any chance to be implemented? What do you (and other) thinks?

Sebagai balasan Séverin Terrier

Re: Preventing Moodle to periodically delete backup directory?

oleh Nicolas Martignoni -
Gambar dari Core developers Gambar dari Documentation writers Gambar dari Particularly helpful Moodlers Gambar dari Plugin developers Gambar dari Testers Gambar dari Translators

Just created MDL-60923. Please comment.

Rata-rata penilaian:Useful (1)