Moodle migration - MoodleDocs (2024)

There may be times when you need to move your Moodle site from one server to another. For example, moving a Moodle site from shared hosting service's server to a dedicated server.

Contents

  • 1 Recommended method
    • 1.1 Turn on maintenance mode
    • 1.2 Backup the Moodle database on the old server
    • 1.3 Restore the database backup to the new server
    • 1.4 Copy moodledata from the old server to the new server
    • 1.5 Copy the Moodle code from the old server to the new server
    • 1.6 Update config.php with the URL of the new server
    • 1.7 Test the copied site
    • 1.8 Update links containing wwwroot in the database
    • 1.9 Take the site out of maintenance mode
  • 2 Quick and hacky method
  • 3 Other considerations
    • 3.1 Upgrade Moodle at the same time?
    • 3.3 Internal and external access
    • 3.4 reCAPTCHA
    • 3.5 Other Documentation
  • 4 See also
  • 5 Any questions?

Recommended method

This involves moving a whole site from one server to another. If you are changing the domain/IP address to the new server you need to do these steps:

Turn on maintenance mode

Place your current Moodle site into Maintenance mode via Site Administration > Server > Maintenance Mode to prevent any further additions to the Moodle database. Don't let administrators login during the migration as they are not affected by the maintenance mode setting.

Backup the Moodle database on the old server

The right way to back up your database depends on which database system you are using. The instructions below are one way to back up a MySQL database. Another option would be to use a tool like phpMyAdmin to manually make a backup. The documentation for your database will give more options. There are many ways to do such backups. Here is an outline of a little script you can run from command line on Unix to backup the database:

cd /my/backup/directorymv moodle-database.sql.gz moodle-database-old.sql.gzmysqldump -h example.com -u myusername -p'mypassword' -C -Q -e --create-options mydatabasename > moodle-database.sql

If you only write "-p" without your password, you will be prompted for it.

Restore the database backup to the new server

Copy the database back up files to the new server and restore into the new database server.

Once you have created the new database on the new server:

mysql -p new_database < moodle-database.sql

For other databases, follow their instructions for restoring a backup.

Copy moodledata from the old server to the new server

Copy the contents of your data directory (check for the value in $CFG->dataroot) to the new server. This can be a lot of data, so consider using a good data copying tool like rsync. If using an FTP client, the transfer of the filedir folder must be in BINARY mode or the files will get corrupted in the process.

NB: It is not necessary to copy the contents of these directories:

  • /moodledata/cache
  • /moodledata/localcache
  • /moodledata/sessions
  • /moodledata/temp
  • /moodledata/trashdir

Omitting these files will reduce transfer time substantially.

Check the file permissions of the copied files. The web server needs read and write access.

Copy the Moodle code from the old server to the new server

You will need to copy the Moodle code itself to the new server (this is the Moodle folder found in your webroot folder e.g. /var/www or public_html).

Check the file permissions of the copied files. The web server needs read access.

Update config.php with the URL of the new server

If the migration will move Moodle to a new URL, then update $CFG->wwwroot in config.php to point to the new location.

Also check the other properties there. Is the path $CFG->moodledata still correct? Do the database connection settings need to be changed? While you're at it, potentially consider making a new config.php from the latest config-dist.php, to give you more config override options in the future, should you need them.

Test the copied site

You should now be able to log into the new site as admin, and verify that most things are working.

Update links containing wwwroot in the database

The one thing we have not fixed is any internal links stored in the database. To fix these use the Search and replace tool by going to {wwwroot}/admin/tool/replace/index.php.

Enter the url for your old server (https://oldserver.com/) and new server (https://newserver.com/) and it will fix any links stored in the database.

Take the site out of maintenance mode

Test the migration some more, then when you are satisfied, remember to take the site out of maintenance mode.

Quick and hacky method

If you have shell access on both servers, here is a quick command-line based method.

  • Set up a new empty database on the new server.
  • Place your existing Moodle site into maintenance mode.
  • Login to shell on the old existing server.
  • Use rsync to copy moodledata and public_html or moodle folders (or whatever directory your Moodle install is in) to the new server - execute (replacing caps with your details; SOURCE = the directory you want to copy) for each directory:
rsync -av -e ssh SOURCE/ USERNAME@NEW_SERVER.COM:/PATH/TO/DESTINATION/
  • Dump existing database and move and import into database on new server by executing:
mysqldump --allow-keywords --opt -uMySQL_USERNAME -pPASSWORD DATABASE | ssh USER@DOMAIN "mysql -uMySQL_USERNAME -pPASSWORD DATABASE"
  • Replace any links in the database that contain the full site URL:
#sed -e 's/oldserver.com/newserver.com/g' oldmysqldump.sql > newmysqldump.sql
  • On the new server, update config.php with relevant details where applicable (e.g. database name and user details, the wwwroot and the dataroot).
  • Check ownership and permissions are correct on both moodle code and moodleData directories.
  • Make sure everything is working.

Takes about 15 minutes for a small site. However, transferring several Gigabytes of data for a larger site can take hours depending on your network connection and hard drive read/write speed.

When you are happy all has gone well, set up redirects/make DNS changes if required, take new site out of maintenance mode and "switch off" old site.

  • If you are switching the IP address from the old server to the new one, you will need to turn off the old server before firing up the new one to avoid IP addressing conflicts and confusion!

Other considerations

Upgrade Moodle at the same time?

While doing the work of migrating Moodle, you might want to upgrade Moodle to the latest version at the same time. On the other hand, if you do that, and something breaks, you won't be sure which change caused the problem, so the more cautious approach is to change one thing at a time, and test in between to verify that all is well.

Also consider PHP Versions - if you're looking to upgrade PHP as part of the process on the new server, then you'll have to make sure the Moodle Version you're copying across supports both the PHP Versions.

DNS & masquerading changes

You may have had to change the DNS entries for the new Moodle site. If you have done so, it will take some time for the changes to replicate, so be patient. If your server is located behind a firewall, you may also have to change your firewall rules to allow access to the new server. See the masquerading docs.

Internal and external access

If you have a set up where your Moodle site can be accessed via a network and via the internet, ensure you check that the new site can be accessed internally and externally.

reCAPTCHA

If you migrate to a new domain and have setup Email-based self-registration, you need to create new API-Keys at google. You will find the explanation and links to google in Email-based self-registration.

Other Documentation

One other thing to consider is to have a look at all the installation documents for everything you're going to migrate to - e.g. Webserver (Apache/Nginx/OpenLiteSpeed), MariaDB/MySQL, Redis cache store, Microsoft 365 and also the initial Moodle Installation Guide as more specific setup steps are present within each, but it'll also give you an idea as to what you may need to (re)setup on your new server as well.

See also

  • Site backup
  • Site restore
  • Backup and restore FAQ
  • Performance recommendations

Any questions?

Please post in the Installing and upgrading help forum on moodle.org

Moodle migration - MoodleDocs (2024)

FAQs

How to migrate Moodle from one server to another? ›

Recommended method
  1. Turn on maintenance mode. ...
  2. Backup the Moodle database on the old server. ...
  3. Restore the database backup to the new server. ...
  4. Copy moodledata from the old server to the new server. ...
  5. Copy the Moodle code from the old server to the new server. ...
  6. Update config. ...
  7. Test the copied site.
Jan 11, 2024

How can I make my Moodle site faster? ›

Boosting Moodle Performance – Tips To Speed Up Your Moodle...
  1. 1: The Basic Tweaks. ...
  2. 2: Get a Managed Moodle Cloud Hosting. ...
  3. 3: Baseline Monitoring. ...
  4. 4: Operating System. ...
  5. 5: Additional Performance Tweaks for Desktops. ...
  6. 6: PHP Accelerators to less the CPU load. ...
  7. 7: Check Memory Limit. ...
  8. 8: Optimize the Performance of Apache Server.

How do I update my URL in Moodle? ›

How to change the Moodle site URL
  1. Access your account using SSH or cPanel.
  2. Using the command line or cPanel File Manager, navigate to the directory where Moodle is installed.
  3. Using your preferred text editor, open the config. ...
  4. Locate the line in the file that begins $CFG->wwwroot.
  5. Save your changes to the config.

How do I update Moodle? ›

To do this just go to Site administration > Notifications. Moodle will automatically detect the new version and perform all the SQL database or file system upgrades that are necessary. If there is anything it can't do itself (very rare) then you will see messages telling you what you need to do.

How do I import content from one Moodle course to another? ›

From Course navigation > More > Course reuse, select 'Import'. Select the course you wish to import from and click Continue. You will be presented with the "backup settings" page. Use the check boxes for import activities, blocks and or filters as types of items which will show on the next screen.

How do I copy Moodle activities or resources from one course to another? ›

Import items into the target course
  1. Open the course you want to import item(s) into.
  2. Select the Course Management button (black gear icon. ...
  3. On the Course Management panel, under Course Settings, select Import course or activities. ...
  4. Note: Courses are deleted from Moodle 18 months after the end of the semester taught.

What is the URL of my Moodle Site? ›

If you don't know the address of your Moodle site, here's how you can find it: Open a web browser (like Chrome or Safari) and go to your school's Moodle site login page. At the top of the page in the address bar, you'll see the URL address of your Moodle site, e.g. “campus.example.edu”.

How do I search and replace a URL in Moodle? ›

Admins can search and replace text e.g. URLs in their Moodle database using the search and replace tool at http://yourmoodlesite.org/admin/tool/replace/index.php (replacing yourmoodlesite.org with the address of your Moodle site).

How long does it take to update Moodle? ›

Once they make the change, it will take about 24 hours to update in Moodle.

What is the current version of Moodle? ›

Moodle 4.4.3

This is the latest official update of Moodle 4.4.

Why upgrade Moodle? ›

Supported Version:

Some older Moodle versions are simply no longer supported. This means that there are no more security reviews or bug fixes by Moodle's core developers. You can see if your version is supported by Moodle HQ here.

How often is Moodle updated? ›

Moodle has major versions – for example, 4.1, 4.2, 4.3 and 4.4 – released every six months, and these have minor versions – for example, 4.1, 4.1. 1, 4.1. 2, released every two months. Between the minor versions weekly updates are released with the latest fixes.

How do I transfer from one server to another? ›

After migration, you can process the decommissioned source servers, and reissue certificates on your new destination server.
  1. Step 1: Install migration service and check firewall. ...
  2. Step 2: Create job and inventory server data. ...
  3. Step 3: Transfer data to destination servers. ...
  4. Step 4: Cut over to new servers.
Jun 25, 2024

How do you migrate data from one server to another? ›

There are five major steps in the server migration process, and each has its importance in ensuring success.
  1. Step 1 – Prepare the New Server. ...
  2. Step 2 – Access Data Fidelity. ...
  3. Step 3 – Transfer the Data. ...
  4. Step 4 – QA Testing. ...
  5. Step 5 – Change DNS, Go Live.
Apr 20, 2023

Can you export from Moodle? ›

Moodle can export all files using the Download course content feature. The export also includes a simple web page showing all the items on the main course page, including links to the downloaded files.

How to migrate a website from one server to another perfectly? ›

How to transfer web hosting step-by-step
  1. Choose a new hosting provider. ...
  2. Save your website's files. ...
  3. Export your database. ...
  4. Create a new database. ...
  5. Import your database. ...
  6. Modify your website's files. ...
  7. Upload your website's files. ...
  8. Test your website.
Dec 21, 2022

Top Articles
How to Factory Reset PC Without Losing Data in Windows
Remove Files and Clean the Drive: How to Wipe Windows 10 Laptop PCs
Accuweather 15 Day Weather Forecast Philadelphia
Beaufort Mugshots Last 30 Days
The Hague (Netherlands) weather
Gomovies Spiderman
Q-global Web-based Administration, Scoring, and Reporting
Free Inter Tv Live
415-261-2242
North Bay Craigslist Jobs
Huntsville Body Rubs
One Facing Life Maybe Crossword
Wyze Recover Deleted Events
Who Is Mikaylah? Age, Boyfriend, Net Worth, Wiki & More
Joy Ride 2023 Showtimes Near Marcus Oakdale Cinema
Milking Table Orange County
Van der Poel kleurt EK op kasseien, maar Merlier wint sprint vlak voor Kooij
VesalBlood ALTERNE: Diesem Fernen Traum - Ri47
Unitek Enrollment Portal
mikroC PRO for PIC | Mikroe
Flake - RimWorld Wiki
Paddie’s Polygel Nail Expert Kit
Ics 200 Answers
Craigs List Rochester
Bert Kish Longmire
Ac-15 Gungeon
Fatal collision forces police to shut down traffic at 71st Street and Yale
Bad Moms 123Movies
Julez Garcia Ogden Utah
Otterbrook Goldens
Marshall School District (2024-25) - Marshall, MO
Realidades 2 Capitulo 2B Answers
Michigan Medicine Vpn
Weil Cornell Connect
Rising Periscope Ru
X Abused Reader
Mikahhlynn Instagram
Trivago Walt Disney World
Where To Cook In Gerudo Town
Ellen Knight Casper Wyoming
Renfield Showtimes Near Paragon Theaters - Coral Square
Sumo Wrestling Wiki
Aultman.mysecurebill
Mister Guns Plano Range
Restored Republic January 20 2023
Box Csun
Serenity Nail Salon Brentwood Tn
Syracuse Pets Craigslist
Puretalkusa.com/Amac
Teresa Palmer Fansite
Latest Posts
Article information

Author: Moshe Kshlerin

Last Updated:

Views: 6548

Rating: 4.7 / 5 (57 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Moshe Kshlerin

Birthday: 1994-01-25

Address: Suite 609 315 Lupita Unions, Ronnieburgh, MI 62697

Phone: +2424755286529

Job: District Education Designer

Hobby: Yoga, Gunsmithing, Singing, 3D printing, Nordic skating, Soapmaking, Juggling

Introduction: My name is Moshe Kshlerin, I am a gleaming, attractive, outstanding, pleasant, delightful, outstanding, famous person who loves writing and wants to share my knowledge and understanding with you.