Guides · Migrations

Restoring a Moodle course backup that is too large

The Pulse data confidence page showing how fresh each source is.

The backup is safely on your computer, you choose it on the restore page, and Moodle replies: "The file you tried to upload is too large for the server to process." The backup is fine. The upload is hitting a ceiling set somewhere between the browser and Moodle. This guide shows where those ceilings are, and three ways to get the course restored.

Menu names are from the Moodle 5.3 documentation.

The four limits

Moodle documents four levels of upload limit. Each one caps the levels below it, so the lowest one wins.

Level Where it is set Bounded by
1. Server and PHP php.ini, the web server's own configuration, outside Moodle Nothing in Moodle
2. Moodle site Site administration > Security > Site security settings > Maximum uploaded file size Level 1
3. Course A further restriction on the course settings page Level 2
4. Activity The activity's settings Level 3

The documentation is clear that Moodle cannot override the server or PHP settings. If level 1 is set low, raising the site's maximum does nothing: the drop-down cannot go above what PHP and the web server allow.

Route 1: raise the server limits

For a site that restores large courses often, raise level 1 and then level 2.

PHP. In php.ini, change three settings: post_max_size, upload_max_filesize and max_execution_time. The documentation suggests 600 for the execution time. There can be more than one php.ini on a server; running phpinfo() shows which one is in use.

Apache. The same three values can be set with php_value lines in the .htaccess file at Moodle's root, if Apache allows overrides there.

Nginx. Add client_max_body_size to the http section of the main configuration. If the site uses SSL, set it in the SSL server and location blocks as well.

IIS. Under Request Filtering, set "Maximum allowed content length", in bytes. The documented default is about 28.6 MB, so check it before anything else on an IIS server. Under FastCGI Settings, the documentation sets Activity Timeout and Request Timeout to 3600.

Then set Maximum uploaded file size for the site, and check the course's own limit is not lower.

Route 2: restore from the command line

For a one-off large course, the documented route skips the upload altogether. From Moodle 3.10, site administrators can run admin/cli/restore_backup.php on the server:

  • --file: the path to the .mbz file on the server
  • --categoryid: the id of the category to restore into
  • --showdebugging: show developer-level debugging if something goes wrong

The backup needs to reach the server by whatever route the server team allows. The restored course appears in the chosen category. The Moodle FAQ points to this route, and its partner admin/cli/backup.php, for very large courses.

Route 3: make the backup smaller

Often the course does not need everything in the backup. When you make the backup again, the Initial settings let you choose whether to include users, user files, comments, completion details, course logs and grade history, and the Schema settings let you leave out activities you do not want. Course logs and grade history are off by default.

A backup made with no users ends in -nu.mbz; a backup with no files gets -nf. Our guide to a Moodle backup without user data covers what a no-user backup leaves out and when that is the right copy anyway.

Which route to use

Situation Route
Large restores are routine on this site 1, then keep it documented
One very large course, and an administrator with server access 2
The backup holds user data or files the new course does not need 3
IIS with default request filtering 1: the default is about 28.6 MB
The restore uploads, then sits on pending Not a size problem: see restore stuck on pending

Two things size will not explain. A backup restores to the same Moodle version or a newer one; restoring into an older site can fail whatever the file size. And if the backup never finished in the source course, start with the backup stuck or pending guide.

A worked example

At a demo university a module with years of video uploads produces a 3 GB backup for rollover. The restore page refuses it with the "too large for the server" message.

  • The administrator checks phpinfo(): upload_max_filesize is far below that, so the site setting was never the cap.
  • The team does not want 3 GB uploads through the browser every summer, so it skips route 1.
  • The module leader makes a new backup without users or user files. The file is still large because the course's own videos are inside it.
  • The administrator copies that file to the server and restores it with restore_backup.php into the new year's category.

The course restores in one pass. The team adds a note to its rollover plan, with an owner: large courses go by the command line.

Open issues, each with what was observed, the courses affected and an owner

Then check what came across

A restored course carries last year's dates, links and file references with it. Once you have a backup made without user data, Bradawl Content Check can read it. It works with Moodle, runs in your browser and sends nothing anywhere, so a large file never leaves your machine, and it lists the leftovers the rollover checklist describes. It has been tested on invented data, and no findings is not a sign-off that a course is ready. Download Content Check, or see all the free tools.

Moodle is a trademark of its owner. Bradawl is independent and not affiliated with it.

Related guides

Panopto, Blackboard, Moodle, Canvas and Microsoft Teams are trademarks of their owners. Bradawl is independent and not affiliated with them.