Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-32547

Configure temporary file deletion, to avoid moodledata/temp/backup filling up the filesystem

XMLWordPrintable

    • MOODLE_22_STABLE, MOODLE_26_STABLE
    • MOODLE_29_STABLE
    • wip-MDL-32547-master-v2
    • Hide

      Not a solution to the tempdir\backup filling with failed backups but to allow large backups to complete fully run automated backup via cli (be aware of this issue http://tracker.moodle.org/browse/MDL-32548 )

      Show
      Not a solution to the tempdir\backup filling with failed backups but to allow large backups to complete fully run automated backup via cli (be aware of this issue http://tracker.moodle.org/browse/MDL-32548 )
    • Hide
      1. Create a course.
      2. Create a failed backup. I edited the backup_stepslib.php file and put a die(); in one of the functions.
      3. Check moodledata/temp/backup and ensure that there are directories listed there.
      4. Update the scheduled task "Delete stale temp files" [Site administration ► Server ► Scheduled tasks] and change all of the times to '*'.
        • You can either Wait an hour [Site administration ► Server ► Cleanup ] and set 'Clean up temporary data files older than' to '1 hours'.
        • Or change the scheduled task code [lib/classes/task/file_temp_cleanup_task.php]

          $time = time() - ($CFG->tempdatafoldercleanup * 3600);
          

          to

          $time = time() - 1;
          

      5. Run the cron.
      6. Have a look in the temp/backup directory and check that all of the directories have been removed.
      Show
      Create a course. Create a failed backup. I edited the backup_stepslib.php file and put a die(); in one of the functions. Check moodledata/temp/backup and ensure that there are directories listed there. Update the scheduled task "Delete stale temp files" [Site administration ► Server ► Scheduled tasks] and change all of the times to '*'. You can either Wait an hour [Site administration ► Server ► Cleanup ] and set 'Clean up temporary data files older than' to '1 hours'. Or change the scheduled task code [lib/classes/task/file_temp_cleanup_task.php] $time = time() - ($CFG->tempdatafoldercleanup * 3600); to $time = time() - 1; Run the cron. Have a look in the temp/backup directory and check that all of the directories have been removed.
    • BACKEND Sprint 18

      If backup tries to backup a large course and the backup fails to complete successfully a large amount of disk can be taken up in moodledata/temp/backup. Further attemps to complete the same course backups will not reuse the temp directory contents or clean out old contents but instead start again.

      This can cause disk space usage to grow to hit limit imposed by host or disk capacity with little or no notification to site admin or entry in server logs. Site functionality could also be affected if no space available for new courses/resources to be added. Unknowningly users with backup permissions could crash site by repeating command to backup large course and fill allocated disk space with incomplete course backups

      A side affect of this is non-moodle based backups of db and files take longer because contents of tempdir is larger than necessary

      To reproduce:
      Attempt to backup a large course either manually from backup UI or via automated backups configured via UL. Monitor the moodledata/filedir/temp/backup When the backup fails due to timeout of apache or php (e.g html error 500) the contents will remain along with an blank .log file with the same name as the temp folder which was created, in my case just under 10GB for 1 course
      rerun the backup again and a new folder will be created in the temp directory but without cleaning up the 1st attempt

      Possible Cures:
      1) Log start time of backup in logs, with progress updates entered and if backup is not completed in X hours delete the contents of temp\backup folder and notify admin. This would also help admins know how far backups get before they fail.

      2) Allow site admin/backup user to see list of tempdir on backup screen and clear as needed

      3) Possibly wider benefit from this but allow site admin to list temp dir size and contents and set "time to live" value for contents before cleaned up by cron process

      4) Emergency Option if files.api reports problems writing to disk due to insufficient space prompt admin to empty tempdir so users not affected.

      5) Impose quota on tempdir size set by site admin and include checking in cron process to warn admin if quota is neared

            abgreeve Adrian Greeve
            mobcdi Michael OBrien
            Ankit Agarwal Ankit Agarwal
            Dan Poltawski Dan Poltawski
            Rajesh Taneja Rajesh Taneja
            Votes:
            8 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.