Bobcares

Moodle Migration to AWS

by | Apr 8, 2024

Learn all about Moodle Migration to AWS from our experts. Our Moodle Support team is here to help you with your questions and concerns.

Moodle Migration to AWS

Are you planning to migrate your Learning Management System to AWS?

Moodle Migration to AWS

Well, you have come to the right place!

Before you start our experts would like to point out that it is crucial to back up your database before the migration.

Our experts have put together this guide to help you through the migration process.

Database Backup

Before migrating to AWS, we have to back up our database from the current LMS. To optimize time and storage, we can dump the database into a gzipped file. Here’s how you can do it.

Before we begin, open a terminal window and use the “screen” command, to make sure the backup process continues running even when the terminal is closed.

We can create a screen session with a descriptive name as seen here:

`screen -s session_name`

To detach the screen session, press “Ctrl+a+d”.

Also, we can list all active screen sessions as seen here:

screen -ls

We can reattach a screen session with this command:

screen -x screen_id

Now it is time to start with the backup process. First, create a shell script (backupDB.sh) to automate the database backup process. Here’s a sample script:

#!/bin/bash
dt=$(date +"%Y%m%d_%H%M%S")
name=db_elearning_$dt.sql.gz
mysqldump -uDBUSER -pDBPASS DBNAME | gzip > /home/undiksha/db_toAWS/db_elearning$name

Migrating Data to AWS

Once the database backup is complete, we can migrate the data to AWS. Follow these steps:

  1. First, install AWS CLI and configure access keys obtained from IAM Users. Also, in IAM users, we have to attach AmazonS3FullAccess permission policies.
  2. Then, create an AWS S3 bucket to store the LMS files. This includes Moodle Data, Database Gz, and Source Code.
  3. Now, we can use AWS CLI commands to sync data to our S3 bucket.

    For example:
    aws s3 cp /home/elearning/ s3://elearningdata/
    aws s3 cp /home/bobcares/db_toAWS/ s3://elearningdata/db

We can import the database into AWS, with this command:

zcat db_elearningbackup_db_elearning_2024123_5467.sql.gz | mysql -u root -p db_elearning

After that, we can reduce storage costs using EBS. We can mount S3 to our EC2 instance using s3fs. We upload moodledata from on-premise to S3 in elbucket.bobcares at folder data in this sample script:

#!/bin/bash
s3fs elbucket.bobcares /home/ubuntu/s3_elearning \
-o passwd_file=/home/ubuntu/.s3fs-creds \
-o endpoint="ap-southeast-3" \
-o url="https://s3.ap-southeast-3.amazonaws.com" \
-o allow_other,nosuid,mp_umask=0007,uid=33

Now, it is time to update the config.php file of Moodle to set the data root to the mounted S3 location:

$CFG->dataroot = '/home/ubuntu/s3_elearning/data';

Alternatively, we can use VMware tools to convert our physical machine to a virtual image, and then use the AWS VM Import tool to upload the image to AWS. Remember to harden the server’s security and optimize its resources before finalizing the migration.

Then, follow the instructions to create a Key Pair. This lets us ssh to the server.

Let us know in the comments if you need further help with the migration process.

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

In brief, our Support Experts demonstrated how to migrate Moodle to AWS.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.