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

When removing excess backups we should read the backup XML file

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.2
    • Fix Version/s: 2.4
    • Component/s: Backup
    • Labels:
    • Testing Instructions:
      Hide

      Test pre-requisites

      The following can be found in Home ► Site administration ► Courses ► Backups ► Automated backup setup

      • backup_auto_active to Enabled
      • backup_auto_storage to Specified directory for automated backups
      • backup_auto_destination to your moodledata/backups
      • backup_auto_keep to 2
      • backup_shortname to False (unticked)
      • Wait 2 minutes between each CLI command specified below (This is important!)
      • The number of backups to have is the number of backups PER course

      Test steps

      1. Run php admin/cli/automated_backups.php 3 times. Bash script for your convenience: php admin/cli/automated_backups.php; for i in {1..2}

        ; do echo 'Waiting...' && sleep 120 && php admin/cli/automated_backups.php; done; echo 'DONE'

      2. Make sure you have no more than 2 backups in your backup directory
      3. Set backup_shortname to True (unticked)
      4. Run php admin/cli/automated_backups.php
      5. Make sure you have 2 backups, the newest using the shortname, the other one not
      6. Set backup_shortname to False (unticked)
      7. Make sure you have 2 backups, the oldest using the shortname, the other one not

      Destructive test

      1. Drop some other files in the backup directory
        • Fake zips
        • Use similar file names
        • Rename a course with another
        • ...
      2. Run the CLI and make sure only the right files are deleted!

      (Setting backup_auto_keep to a higher value might help here.)

      Show
      Test pre-requisites The following can be found in Home ► Site administration ► Courses ► Backups ► Automated backup setup backup_auto_active to Enabled backup_auto_storage to Specified directory for automated backups backup_auto_destination to your moodledata/backups backup_auto_keep to 2 backup_shortname to False (unticked) Wait 2 minutes between each CLI command specified below (This is important!) The number of backups to have is the number of backups PER course Test steps Run php admin/cli/automated_backups.php 3 times. Bash script for your convenience: php admin/cli/automated_backups.php; for i in {1..2} ; do echo 'Waiting...' && sleep 120 && php admin/cli/automated_backups.php; done; echo ' DONE ' Make sure you have no more than 2 backups in your backup directory Set backup_shortname to True (unticked) Run php admin/cli/automated_backups.php Make sure you have 2 backups, the newest using the shortname, the other one not Set backup_shortname to False (unticked) Make sure you have 2 backups, the oldest using the shortname, the other one not Destructive test Drop some other files in the backup directory Fake zips Use similar file names Rename a course with another ... Run the CLI and make sure only the right files are deleted! (Setting backup_auto_keep to a higher value might help here.)
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-35117-master

      Description

      The backup helper which removes the excess backups could be improved. As we've seen in MDL-33812 and MDL-35116 relating on file names can lead to unexpected results. Relating on the last modification date provided by the file system can be a problem as well, some file system inaccurately update this value.

      We should think of a way of improving things by reading the XML file in the backups which is the most accurate data we can get. It includes course IDs, timestamps, etc...

      Here is a pastie of very quick way of retrieving information from a backup file, it only serves as an example. http://pastie.org/4608454

      This implementation should be checked for performance issues, as extracting a file from thousands in a backup zip could take a while.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  3/Dec/12