moodle download saves what the course page offers. dl and get are aliases of the same command.
What you can download
UNIT TASK phrase resolved the same way as Daily use. It can name:
- one activity: a resource, every file in a folder, or the files attached to an assignment (its brief, datasets);
- a whole section, by phrase (
"UNIT week 5") or by section URL (…/course/view.php?id=34637§ion=5), including child sections the page shows inside it; - a single file link (
…/pluginfile.php/…).
? is a glob character.
Browse when you are not sure
download walks unit, then section, then item, the way the course page does. Type to filter and press Escape to go back a step. moodle dl UNIT starts at that unit’s sections.
Where files land
A file already at the destination is skipped, so rerunning a section after Ctrl+C or a dropped connection fetches only what is missing. The same document linked twice is saved once, and two different files with one name get a
(2) suffix.
-o, --output <file> is different: it writes the command’s own output (the summary of what was saved) to a file, not the downloaded file.
moodle activities show ID; it lists the files download would save.
Keep units in sync
moodle sync keeps one folder per unit in step with Moodle: resources, folder contents and assignment attachments, laid out by section. Pages and books are saved as single HTML files with their images embedded, so they read the same offline.
--dry-run reports what would change without writing anything.
- A rerun asks Moodle only whether each file changed, and usually downloads nothing.
- A changed file replaces your copy only when you have not edited it. An edited copy stays put and the new version lands beside it as
name (updated YYYY-MM-DD).ext. - Files removed from Moodle are reported and kept locally. A file you delete stays deleted until Moodle changes it.
- Each unit folder holds a
.moodle-sync.jsonfile that records which unit it mirrors, so you can rename or move the folder freely.
Failure modes
- A reference that matches several items lists the candidates instead of guessing. At a terminal you pick one.
- Moodle returning a sign-in page instead of a file means the session expired. Run
moodle auth login. - An existing file is never overwritten without
--force.