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

Make fileless backups try even harder to restore from trash

XMLWordPrintable

    • MOODLE_25_STABLE
    • Hide

      Note: For easiest testing, start with a clean install of Moodle (highly recommended).
      This is because we need to test restoration of de-duplicated files and want to 100% ensure that the files aren't already in use elsewhere in the interface.

      These testing instructions try to test:

      • file-less course restore
      • file-less course restore after a file has been deleted but still exists in the files table
      • file-less course restore after a file has been deleted but still exists in the trash directory
      1. Create a new course
        • an image as a label
        • a folder with some files
        • Confirm that the files are in the moodledata directory (keep this window open for comparison in a minute*
      2. Edit backup/backup.php to change the mode from MODE_GENERAL to MODE_SAMESITE
      3. Back up the course (download the backup file)
        • Confirm that the backup log states that the file inclusion setting has been set to '0'
      4. Unzip the backup
        • Confirm the files are NOT present in the files directory
        • Confirm that the files.xml file contains appropriate metadata
        • Confirm that moodle_backup.xml incudes a include_files setting of 0
      5. Delete the course in it's entirety
      6. Create a new course
      7. Restore from the most recent backup (the one generated by a hacked backup.php)
        • Confirm that you were not shown a warning about missing files
      8. View the new course
        • Confirm that the files are all present (they should be restored based upon the contenthash from the trash directory)
      9. Delete the course in it's entirety again
      10. Run the attached script (40445-purge-files.php)
        • This removes deleted files from the files table but not from the trash directory
        • Confirm that the files are now gone from the files table (if you started with a fresh site, the table should be mostly empty)
      11. Create a new course
      12. Restore from the most recent backup (the one generated by a hacked backup.php)
        • Confirm that you were not shown a warning about missing files
      13. View the new course
        • Confirm that the files are all present (they should be restored based upon the contenthash from the trash directory)
        • Confirm the files ARE present in the files directory
        • Create a new course
        • Import from the newly previous course
      14. View the new course
        • Confirm that the files are all present (they should be restored based upon the contenthash from the trash directory)
        • Confirm the files ARE present in the files directory
      Show
      Note: For easiest testing, start with a clean install of Moodle (highly recommended). This is because we need to test restoration of de-duplicated files and want to 100% ensure that the files aren't already in use elsewhere in the interface. These testing instructions try to test: file-less course restore file-less course restore after a file has been deleted but still exists in the files table file-less course restore after a file has been deleted but still exists in the trash directory Create a new course an image as a label a folder with some files Confirm that the files are in the moodledata directory (keep this window open for comparison in a minute* Edit backup/backup.php to change the mode from MODE_GENERAL to MODE_SAMESITE Back up the course (download the backup file) Confirm that the backup log states that the file inclusion setting has been set to ' 0 ' Unzip the backup Confirm the files are NOT present in the files directory Confirm that the files.xml file contains appropriate metadata Confirm that moodle_backup.xml incudes a include_files setting of 0 Delete the course in it's entirety Create a new course Restore from the most recent backup (the one generated by a hacked backup.php) Confirm that you were not shown a warning about missing files View the new course Confirm that the files are all present (they should be restored based upon the contenthash from the trash directory) Delete the course in it's entirety again Run the attached script (40445-purge-files.php) This removes deleted files from the files table but not from the trash directory Confirm that the files are now gone from the files table (if you started with a fresh site, the table should be mostly empty) Create a new course Restore from the most recent backup (the one generated by a hacked backup.php) Confirm that you were not shown a warning about missing files View the new course Confirm that the files are all present (they should be restored based upon the contenthash from the trash directory) Confirm the files ARE present in the files directory Create a new course Import from the newly previous course View the new course Confirm that the files are all present (they should be restored based upon the contenthash from the trash directory) Confirm the files ARE present in the files directory

      At present, file-less backups will try to restore a deleted file only if the file record still exists in the file table.

      However, many of us run in such a way that the trash directory is never emptied. In this case, the trash directory remains while the entries in the file table are removed.

      It would be great if we could restore from the trash directory and use the metadata in the backup.

      This may require some API changes to file_storage as:

      • it would be bad (and wrong) to calculate the trash path outside of file_storage
      • it would be bad to call file_storage::trash_path_from_hash() outside of file_storage because the underlying file system may change to a non-filesystem store
      • file_storage::try_content_recovery($file) takes a file record assuming it already exists in the database

      We need a function like create_file_from_pathname() which restores the file instead.

            Unassigned Unassigned
            dobedobedoh Andrew Lyons
            Petr Skoda Petr Skoda
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 minute
                1m

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