Automated Course Backup

Automated Course Backup

by Svenja Lell -
Number of replies: 3

Hi there,


on our Moodle site (Moodle 3.5) we run automated course backups which is configured here:


<moodledomain>/admin/settings.php?section=automated

"backup_auto_storage" for instance is switched to:

"Course Backup filearea and the specified directory"



That runs very well except for too files with different error messages

in the backup logs.


1.)  Course abc


4:45:08 AM - backup_auto_failed_on_course Course abc

4:45:08 AM - Exception: storedfilecannotcreatefile

4:45:08 AM - Debug:


2.) Course xyz


4:45:19 AM - backup_auto_failed_on_course  Course xyz

4:45:19 AM - Exception: cannot_create_directory /datafolder/moodle/temp/backup/16cd81afd25ae096b082568ededfeda4/files/bc

4:45:19 AM - Debug:



Can you explain what is the prob here. I was able to create a course backup maunally

via the web interface.


The "/datafolder" represents a partition.

That leads onto something else. For days now I see that the /datafolder - partition (size: 380 G) gets full every second day. The trashfolder /datafolder/moodle/trashdir grows rapidly. E.G.100 G a day.

One day the partition was even full.


Can you get we started here on hoe to limit the data growth in the trash folder and

on how to repair the Course backup ?


Thanks a lot!



Kind Regards,


Svenja


Average of ratings: -
In reply to Svenja Lell

Re: Automated Course Backup

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

It would appear that the permissions on your backup folder are not set up correctly.  You have to have the correct permissions so that files can be written/deleted etc...

In reply to Emma Richardson

Re: Automated Course Backup

by Svenja Lell -
Hi Emma,

that's of course a good guess ... but www-data user which runs the Moodle cronjob as sufficient privileges to delete the files in the trashfolder.

1.) This is our datafolder:

root@moodleserver:/data2/moodle# ls -al
...
drwxrwxrwx 10 www-data www-data 12288 Nov 13 14:11 temp
drwxrwxrwx 7 www-data www-data 4096 Nov 13 18:17 trashdir
root@moodleserver:/data2/moodle#


2.) example file


root@moodleserver:/data2/moodle/trashdir/2a/ce# ls -al
total 116
drwxrwxrwx 2 www-data www-data 4096 Nov 13 16:00 .
drwxrwxrwx 3 www-data www-data 4096 Nov 13 16:00 ..
-rw-rw-rw- 1 www-data www-data 110558 Nov 5 02:17 2aceeef381c2fe005f56a4d110c045ba549855f5

3.) deletion with www-data - user is possible:

root@moodleserver:/data2/moodle/trashdir/2a/ce# sudo -u www-data /bin/rm /data2/moodle/trashdir/2a/ce/2aceeef381c2fe005f56a4d110c045ba549855f5
root@moodleserver:/data2/moodle/trashdir/2a/ce# ls -al
total 8
drwxrwxrwx 2 www-data www-data 4096 Nov 13 17:26 .
drwxrwxrwx 3 www-data www-data 4096 Nov 13 16:00 ..
root@moodleserver:/data2/moodle/trashdir/2a/ce#

So the privileges are set very generously. Maybe too generously.

However, the prob is right here. The cronjob does not kill the files in the trash folder. Here is root's crontab:

*/15 * * * * sudo -u www-data /usr/bin/php /path/to/moodle/cron.php > /dev/null 2>&1

Can you get me started how to find a solution ? Orphaned files ?


Thanks for you help!


Kind Regards,


Svenja Lell
In reply to Svenja Lell

Re: Automated Course Backup

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Yes, I apparently did not read your original post correctly. Sorry about that. So chances are that the drive is filling up too quickly. I have also seen that issue with the tmp directory. Sadly, I do not have a fix for this. I had a time when my external mount was not mounted and moodle kept backing up to the temp folder and filled up the local hard drive and I about lost the site. Normally when the backups complete the tmp folder will be cleared out. I thought the trashdir was related to the recycle bin which has its own settings for deletion so it confuses me that that is continuing to grow. Have you checked your recycle bin settings - or maybe I am wrong in my assumption on that folder.