How to Move Moodle to a New Server
All of our Moodle themes are now fully compatible with Moodle 5.3

How to Move Moodle to a New Server

Administrator moving Moodle database, code and files between two servers

Moving Moodle means transferring three connected components—the database, moodledata and the code/configuration—while keeping them consistent. The safest plan separates migration from upgrade. Move the current working version first or upgrade in a separate, tested change window.

Plan the destination

Confirm that the new server supports the existing Moodle release: PHP version and extensions, database version and collation, web server, storage, cron, email, HTTPS and any services such as Redis. For Moodle 5.1 and later, configure the web document root around the new public directory layout.

Record the current values of $CFG->wwwroot, $CFG->dataroot, database settings, reverse-proxy options, session handling and cache stores. Lower DNS TTL in advance if the hostname or address will change.

1. Build and test the new server

Install the required runtime and test permissions before moving real data. A temporary clean installation can confirm that PHP, the database and routing work, but remove the temporary database and data before restoring production.

2. Put the old site into maintenance mode

Announce downtime and stop ordinary-user writes. Administrators can bypass maintenance mode, so avoid editing during the final copy. Pause cron, background integrations and external imports if they could change data.

3. Export the database

Use the database vendor’s supported dump or snapshot tool. Include the correct character set and verify that the export finishes successfully. Compressing the dump can make transfer easier, but retain checksums so you can detect corruption.

4. Copy moodledata

Copy the directory specified by $CFG->dataroot. Binary-safe tools such as rsync are preferable to casual FTP for a large file store. Moodle notes that cache, local cache, sessions, temp and trash directories do not normally need to be migrated; they can be regenerated. Preserve filedir exactly.

5. Copy the code and configuration

Transfer the matching Moodle code, config.php and contributed plugins. Keep code separate from moodledata. Do not introduce a newer Moodle release casually during this step. If infrastructure requires a code rebuild, reproduce the same versions from source control or recorded packages.

6. Restore and update configuration

Create the destination database with the appropriate encoding and collation, import the dump, restore moodledata, then update database credentials and filesystem paths in config.php. Change $CFG->wwwroot only if the public URL changes.

Set secure ownership and permissions. The web service must read code and read/write moodledata, but production code should not be broadly writable.

7. Handle a URL change carefully

If the domain or path changes, use Moodle’s supported search-and-replace tool after a fresh backup. Test embedded links, LTI tools, OAuth redirect URIs, web services, mobile app configuration, payment callbacks and reCAPTCHA keys. External systems may allow only registered domains.

8. Configure cron, email and caches

Create the cron entry on the new host and remove or disable the old one before cutover so jobs do not run twice. Reconfigure SMTP, Redis or Memcached, session storage, antivirus paths, scheduled backups and monitoring. Purge caches after the final configuration.

9. Test before DNS cutover

Use a controlled hosts-file or staging hostname where appropriate. Test administrator, teacher and student login; course files; submissions; grades; quizzes; scheduled tasks; email; large uploads and mobile behaviour. Confirm HTTPS certificates and reverse-proxy headers.

10. Cut over and monitor

Point traffic to the new server, check DNS propagation and keep the old site read-only. Watch error logs, database connections, disk use, task failures and outbound email. Keep the rollback route intact until the new service is accepted.

Migration mistakes to avoid

  • Copying only the code or only the database.
  • Letting both servers run cron.
  • Upgrading PHP and Moodle at the same time without rehearsal.
  • Forgetting plugin, theme or cache dependencies.
  • Using a database search-and-replace without a rollback copy.
  • Deleting the old server before validation and DNS stabilisation.

Final advice

Make every cutover step reversible and assign one source of truth. If the move is also part of a visual refresh, choose a compatible theme from Themes Almond only after the migrated site is technically stable.

Source check: Verified against Moodle 5.3’s official Moodle migration, installation and upgrade documentation.

Leave a Reply

Your email address will not be published. Required fields are marked *