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

Have option to never include files in recycle bin backups

    • MDL-75661-recyclebin-exclude-files
    • Hide
      1. Log in as admin.
      2. Create a course.
      3. Add a file to the course and upload an image to the file.
      4. Set the recycle_bin_exclude_files to 1:

        php admin/cli/cfg.php --set=1 --name=recycle_bin_exclude_files --component=recyclebin
        

      5. Delete the course.
      6. Set 'Clean up trash pool files' to 1 second : Admin > Server > Cleanup.
      7. Ensure draft files are deleted - Modify 'lib/filestorage/file_storage.php' change line 2259 to:

        $old = time(); 

      8. Run:

        php admin/cli/scheduled_task.php --execute='\core\task\file_trash_cleanup_task'
        

      9. Navigate to the recycle bin and restore the deleted course.
      10. Navigate to the file within the course and confirm the image does not exist.
      11. Upload and save another image to the file.
      12. Set the recycle_bin_exclude_files to 0:

        php admin/cli/cfg.php --set=0 --name=recycle_bin_exclude_files --component=recyclebin
        

      13. Delete the course.
      14. Run:

        php admin/cli/scheduled_task.php --execute='\core\task\file_trash_cleanup_task'
        

      15. Navigate to recycle bin and restore the deleted course.
      16. Navigate to the file within the course and confirm the image has been restored.
      Show
      Log in as admin. Create a course. Add a file to the course and upload an image to the file. Set the recycle_bin_exclude_files to 1: php admin/cli/cfg.php --set= 1 --name=recycle_bin_exclude_files --component=recyclebin Delete the course. Set 'Clean up trash pool files' to 1 second : Admin > Server > Cleanup. Ensure draft files are deleted - Modify 'lib/filestorage/file_storage.php' change line 2259 to: $old = time(); Run: php admin/cli/scheduled_task.php --execute= '\core\task\file_trash_cleanup_task' Navigate to the recycle bin and restore the deleted course. Navigate to the file within the course and confirm the image does not exist. Upload and save another image to the file. Set the recycle_bin_exclude_files to 0: php admin/cli/cfg.php --set= 0  --name=recycle_bin_exclude_files --component=recyclebin Delete the course. Run: php admin/cli/scheduled_task.php --execute= '\core\task\file_trash_cleanup_task' Navigate to recycle bin and restore the deleted course. Navigate to the file within the course and confirm the image has been restored.

      I was scratching my head trying to understand why the recycle bin always makes slow / big backups which include the files even when the files are not included due to backup_auto_files being set and discovered this horrible hack:

      https://github.com/moodle/moodle/blob/master/admin/tool/recyclebin/classes/course_bin.php#L115-L124

      The comment there has links to the gory details, and this will get cleaned up in MDL-65228 but it isn't clear when that would get fixed. In the mean time I'd like to propose an almost 1 liner which allows you to set whether recycle bin should include files or not. I would make this a cli only as its a fairly obscure edge case but does have a big performance impact.

      In our inf with objectfs setup and with a policy of never deleting files, then pulling all the files down into these backups is a waste of time and disk and can be eliminated. 

            psistrom Peter Sistrom
            brendanheywood Brendan Heywood
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

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