Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

A guide on how to clone moole into another instance. We take into account that all backups for RDS, EFS and AMI’s for EC2 instances are already set up.

Table of Contents

Restore RDS

Navigate into AWS Console.

We either take a new snapshot or we go into already created snapsots and restore the latest.

Steps in order to take a new snapshot.

  1. Navigate into RDS → DB instances.

  2. Select the database we want to take a snapshot from

  3. Actions → Take Snapshot

  4. We give a name of the snapshot and hit create.

Snapshot it will take approximately 15 minutes to finish.

Restore from a snapshot (Manual or Automated).

  1. Navigate into RDS → Snapshots

  2. Select the snapshot we want to restore

  3. Actions → Restore Snapshot

  4. We navigate into a new window where we must select the appropriate Security Groups and availability zones.

  5. Restore DB instance.

Restore EFS

Take an EFS backup right away

In order to make an EFS backup right away we need to navigate into AWS Backup service.

...

Creating the backup will take approximately 2 hours for 1.4TB

Restore EFS from Backup vaults

In order to restore EFS we need to go into AWS Backup services and then into Backup vaults

...

This action will take approximately 15 minutes.

Mount EFS into EC2 instance

We assume that our instances already have the nescessary php, apache, packages installed.

...

Code Block
sudo mount -fav

Make appropriate changes in HTTPD

We need to log into our ec2 instance. and then navigate into our httpd configuration for moodle

...

Go through the file and make sure we didn’t forget to use the path anywhere else.

Make appropriate changes in moodle config

We navigate to /efstemp/..../moodle

...

  1. we need to make sure the dbtype is the correct one in our case we have 'mariadb'

  2. dbhost,dbname,dbuser,dbpass need to be of the newly restored DB instance.

  3. wwwroot needs to change into the new URL eg https://dev.courses…

  4. dataroot need to point to newly restored EFS with a path to moodledata

  5. session_redis_host need to have the name of the redis for our application

Make sure Redis cache is correct in moodle application

Right after we finish cloning we need to log in into the website.

...

This is an important step as if it’s not configured then changes that are suppose to happen in cloned website will be done into the previous website because of redis caching.

Forbid Access to all users except selected ones

We want to avoid random users to log into the cloned website that’s why we edit moodle/login/index.php

...

Code Block
languagephp
    $allowedUsers = [];
    if (FALSE == (in_array( $user->id, $allowedUsers ))){   
        die('Access Denied');
    }

Extra Steps (disable smtp and crons)

For safety reasons since this is a clone instance of another website (Moodle), it’s better if we disable SMTP and Crons so that we don’t send any notifications in the public accidentally.

...