Get every file out of a Moodle course backup under its original name — Step-by-step guide
A Moodle course backup stores each uploaded file under a hash, so the files inside have names like 43/43aa2e4a... and no folders. MoodleFiles reads the .mbz backup in your browser, restores every file under its original name and folder, and gives you a ZIP plus an index.csv with the path, size, type and hash of each file. Nothing is uploaded.
What the sample produces
The sample is a small course backup written by a script, with folders, a file name that contains an ampersand, a repeated record and a file listed without content. The check reads the same backup with Python's tarfile and xml.etree, compares the SHA-256 and size of every restored file, and checks each row of index.csv. The same files were also tested as a plain tar and as an old-style ZIP backup.
- Course files restored
- 5, under their original folders
- Rows in index.csv
- 5, one per restored file
- Listed but not restored
- 1, reported in the preview
How to use it
- In Moodle, open the course, go to Course administration, choose Backup and make a backup with the default settings. Download the backup file from the course's backup area and keep its .mbz name.
- Choose the .mbz file here. The preview counts the files, the folders, the repeated records and any file the backup does not contain. Nothing is uploaded.
- Download the ZIP. Its folders match the course folders, and index.csv lists the original path, size, type and hash of each file.
Supported files
Reads Moodle 2.x and newer course backups: a gzip-compressed tar (.mbz, .tar.gz) or an older ZIP with files.xml at the top and the hashed files/ folder. Only files.xml and files/ are used. Course structure, activities, grades and the rest of the backup are not converted. Each file goes back under the filepath and filename that files.xml lists; the component and file area do not make folders. Folder records and repeated records of the same file in the same folder are skipped. A file that files.xml lists but the archive does not contain is reported and not restored. Backups made with user data also include student uploads, and those are restored too. Moodle 1.9 backups and encrypted backups are not supported. Names with characters Windows does not allow are changed to underscores. Checked against a generated backup with the same files.xml layout and hashed folders, not a backup from a live Moodle site. Up to 1 GB, read in browser memory.