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.
Navigate into RDS → DB instances.
Select the database we want to take a snapshot from
Actions → Take Snapshot
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).
Navigate into RDS → Snapshots
Select the snapshot we want to restore
Actions → Restore Snapshot
We navigate into a new window where we must select the appropriate Security Groups and availability zones.
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
...
we need to make sure the dbtype is the correct one in our case we have 'mariadb'
dbhost,dbname,dbuser,dbpass need to be of the newly restored DB instance.
wwwroot needs to change into the new URL eg https://dev.courses…
dataroot need to point to newly restored EFS with a path to moodledata
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 | ||
---|---|---|
| ||
$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.
...