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

Automated backups: Add config to exclude events from triggering backups

    XMLWordPrintable

Details

    • MOODLE_400_STABLE
    • MDL-73926-master-v4
    • Hide

      New autobackup config (optional)

      1. NB1: New config and new event helper class are well covered by unit tests.
      2. NB2: This testing is a bit tricky and would require changing data directly in DB which is not really natural from user experience end. Also this is basically what the unit test does. This why this section is marked as optional.
      3. NB3: This test is pretty fragile. eg I had to add tour_ended event as it was occasionally breaking the testing.
      4. Set backup | backup_auto_active to Enabled.
      5. Tick all days for the backup | backup_auto_weekdays setting.
      6. Set backup | backup_auto_skip_modif_days to 10 days.
      7. Set backup | backup_auto_skip_modif_prev to Yes.
      8. Create a course.
      9. Check the course id.
      10. Run \core\task\automated_backup_task scheduled task. 

        php admin/cli/scheduled_task.php --execute="core\task\automated_backup_task"
        

      11. Update mdl_backup_courses table.

        UPDATE mdl_backup_courses SET laststarttime = 1660000000, lastendtime = 1660000000, nextstarttime = 1660000000, laststatus = 1 WHERE courseid = NNN;
        

      12. Run \core\task\automated_backup_task scheduled task one more time. 

        php admin/cli/scheduled_task.php --execute="core\task\automated_backup_task"
        

      13. Confirm, that the course is scheduled for backup.
      14. Run adhoc tasks to actually back up the course by executing . 

        php admin/cli/adhoc_task.php -e
        

      15. Update mdl_logstore_standard_log and mdl_backup_courses tables to emulate all logs and backup happened a month ago.

        UPDATE mdl_course SET timemodified = 1650000000 WHERE id = NNN;
        UPDATE mdl_logstore_standard_log SET timecreated = 1650000000 WHERE courseid = NNN;
        UPDATE mdl_backup_courses SET laststarttime = 1660000000, lastendtime = 1660000000, nextstarttime = 1660000000, laststatus = 1 WHERE courseid = NNN;
        

      16. Run \core\task\automated_backup_task scheduled task.
      17. Confirm, that the course is skipped as not modified.
      18. Reset (update) mdl_backup_courses table to emulate the backup happened a month ago.

        UPDATE mdl_backup_courses SET laststarttime = 1660000000, lastendtime = 1660000000, nextstarttime = 1660000000, laststatus = 1 WHERE courseid = NNN;
        

      19. Create a user.
      20. Enrol the user to the course.
      21. Run \core\task\automated_backup_task scheduled task.
      22. Confirm, that the course is scheduled for backup.
      23. Reset (update) mdl_backup_courses table to emulate the backup happened a month ago.

        UPDATE mdl_backup_courses SET laststarttime = 1660000000, lastendtime = 1660000000, nextstarttime = 1660000000, laststatus = 1 WHERE courseid = NNN;
        

      24. In backup | backup_auto_exclude_events admin setting add \tool_usertours\event\tour_ended, \core\event\role_assigned and \core\event\user_enrolment_created events events
      25. Run \core\task\automated_backup_task scheduled task.
      26. Confirm, that the course is skipped as not modified.
      27. Reset (update) mdl_backup_courses table to emulate the backup happened a month ago.

        UPDATE mdl_backup_courses SET laststarttime = 1660000000, lastendtime = 1660000000, nextstarttime = 1660000000, laststatus = 1 WHERE courseid = NNN;
        

      28. Access the course.
      29. Navigate to question bank and cerate a true/false question.
      30. Add \core\event\question_created event to backup | backup_auto_exclude_events admin setting.
      31. Run \core\task\automated_backup_task scheduled task.
      32. Confirm, that the course is skipped as not modified.
      33. Reset (update) mdl_backup_courses table to emulate the backup happened a month ago.

        UPDATE mdl_backup_courses SET laststarttime = 1660000000, lastendtime = 1660000000, nextstarttime = 1660000000, laststatus = 1 WHERE courseid = NNN;
        

      34. Empty backup | backup_auto_exclude_events admin setting.
      35. Run \core\task\automated_backup_task scheduled task.
      36. Confirm, that the course is scheduled for backup.
      Show
      New autobackup config (optional) NB1 : New config and new event helper class are well covered by unit tests. NB2 : This testing is a bit tricky and would require changing data directly in DB which is not really natural from user experience end. Also this is basically what the unit test does. This why this section is marked as optional. NB3 : This test is pretty fragile. eg I had to add tour_ended event as it was occasionally breaking the testing. Set backup | backup_auto_active to Enabled . Tick all days for the backup | backup_auto_weekdays setting. Set backup | backup_auto_skip_modif_days to 10 days. Set backup | backup_auto_skip_modif_prev to Yes . Create a course. Check the course id. Run \core\task\automated_backup_task scheduled task.  php admin/cli/scheduled_task.php --execute= "core\task\automated_backup_task" Update mdl_backup_courses table. UPDATE mdl_backup_courses SET laststarttime = 1660000000 , lastendtime = 1660000000 , nextstarttime = 1660000000 , laststatus = 1 WHERE courseid = NNN; Run \core\task\automated_backup_task scheduled task one more time.  php admin/cli/scheduled_task.php --execute= "core\task\automated_backup_task" Confirm , that the course is scheduled for backup. Run adhoc tasks to actually back up the course by executing .  php admin/cli/adhoc_task.php -e Update mdl_logstore_standard_log and mdl_backup_courses tables to emulate all logs and backup happened a month ago. UPDATE mdl_course SET timemodified = 1650000000 WHERE id = NNN; UPDATE mdl_logstore_standard_log SET timecreated = 1650000000 WHERE courseid = NNN; UPDATE mdl_backup_courses SET laststarttime = 1660000000 , lastendtime = 1660000000 , nextstarttime = 1660000000 , laststatus = 1 WHERE courseid = NNN; Run \core\task\automated_backup_task scheduled task. Confirm , that the course is skipped as not modified. Reset (update) mdl_backup_courses table to emulate the backup happened a month ago. UPDATE mdl_backup_courses SET laststarttime = 1660000000 , lastendtime = 1660000000 , nextstarttime = 1660000000 , laststatus = 1 WHERE courseid = NNN; Create a user. Enrol the user to the course. Run \core\task\automated_backup_task scheduled task. Confirm , that the course is scheduled for backup. Reset (update) mdl_backup_courses table to emulate the backup happened a month ago. UPDATE mdl_backup_courses SET laststarttime = 1660000000 , lastendtime = 1660000000 , nextstarttime = 1660000000 , laststatus = 1 WHERE courseid = NNN; In backup | backup_auto_exclude_events admin setting add \tool_usertours\event\tour_ended , \core\event\role_assigned and \core\event\user_enrolment_created events events Run \core\task\automated_backup_task scheduled task. Confirm , that the course is skipped as not modified. Reset (update) mdl_backup_courses table to emulate the backup happened a month ago. UPDATE mdl_backup_courses SET laststarttime = 1660000000 , lastendtime = 1660000000 , nextstarttime = 1660000000 , laststatus = 1 WHERE courseid = NNN; Access the course. Navigate to question bank and cerate a true/false question. Add \core\event\question_created event to backup | backup_auto_exclude_events admin setting. Run \core\task\automated_backup_task scheduled task. Confirm , that the course is skipped as not modified. Reset (update) mdl_backup_courses table to emulate the backup happened a month ago. UPDATE mdl_backup_courses SET laststarttime = 1660000000 , lastendtime = 1660000000 , nextstarttime = 1660000000 , laststatus = 1 WHERE courseid = NNN; Empty backup | backup_auto_exclude_events admin setting. Run \core\task\automated_backup_task scheduled task. Confirm , that the course is scheduled for backup.

    Description

      In our case the enrolments are controlled by an external system and there is no point to backup a course if anything changed in the list of enrolments. Anyway once you  restore the course all participants will be unenrolled.

      Would be nice to have a new setting to exclude enrolments events when considering a course as modified and ready for automated backup.

      NB: This has been evolved into Add config to exclude events from triggering backups , so any event(s) can be specified.

      Attachments

        Issue Links

          Activity

            People

              mikhailgolenkov Misha Golenkov
              dmitriim Dmitrii Metelkin
              Dmitrii Metelkin Dmitrii Metelkin
              Adrian Greeve, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo, Matteo Scaramuccia, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 hours
                  4h