How to prepare for a Moodle migration
Before you migrate a Moodle application from your on-premises environment to Azure, you should export your data. This guide explains the steps of the export process.
Install the Azure CLI
Follow these steps to set up the Azure CLI in your on-premises environment:
On a host that you can use for Azure tasks, enter this command to install the Azure CLI:
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bashIn the Azure CLI, enter this command to sign in to your Azure account:
az login -u <username> -p <password>If the Azure CLI opens a browser window or tab, sign in to Azure with your Microsoft account. If a browser window doesn't open, go to https://aka.ms/devicelogin, and enter the authorization code displayed in your terminal.
Create a subscription
Skip this step if you already have an Azure subscription.
If you don't have an Azure subscription, you can create one for free. You can also either set up a pay-as-you-go subscription, or you can create a subscription in the Azure portal.
To use the Azure portal to create a subscription, open Subscriptions, select Add, and enter the required information.

To use the Azure CLI to create a subscription, enter this command:
az account set --subscription '<subscription name>'
An example command is:
az account set --subscription 'ComputePM LibrarySub'
Create a resource group
Once you set up your Azure subscription, create a resource group in Azure using either the Azure portal or the Azure CLI.
To use the Azure portal, follow these steps:
Open Resource Groups, and select Add.
Enter your subscription name, a resource group name, and a region. See Data residency in Azure for a list of available regions. Make a note of the name of the resource group that you enter so that you can use that name in later steps.
Select Review + create.

To use the Azure CLI to create a resource group, enter this command:
az group create -l <region> -n <resource group name> -s '<subscription name>'For example, enter:
az group create -l eastus -n manual_migration -s 'ComputePM LibrarySub'The value you provide with the
-lparameter specifies the default location. Use the same location that you used in previous steps. Make a note of the name of the resource group that you create, and use that name in later steps.
Create a storage account
Next, create a storage account within the resource group that you just created. You'll use this storage account to back up your on-premises Moodle data.
You can use either the Azure portal or the Azure CLI to create a storage account.
To use the Azure portal, follow these steps:
Go to Create storage account.
Enter the following information:
- Your Azure subscription name
- The name of the resource group that you just created
- A storage account name
- Your region
For Account kind, select BlobStorage from the drop-down list.
For Replication, select Read-access geo-redundant storage (RA-GRS) from the drop-down list.
Select Review + create.

To use the Azure CLI to create the storage account, enter this command:
az storage account create -n <storage account name> -g <resource group name> --sku <storage account SKU> --kind <storage account type> -l <region>An example command is:
az storage account create -n onpremisesstorage -g manual_migration --sku Standard_LRS --kind BlobStorage -l eastusThe
--kindparameter specifies the storage account's type.
Back up on-premises data
Before backing up your on-premises Moodle data, turn on Maintenance mode on your Moodle website by following these steps:
From the Moodle instance in your on-premises environment, enter this command:
sudo /usr/bin/php admin/cli/maintenance.php --enableEnter the following command to check the status of your Moodle website:
sudo /usr/bin/php admin/cli/maintenance.php
You should back up on-premises Moodle and moodledata files, configurations, and databases to a single directory. The following diagram summarizes this recommendation:

Create a storage directory
Before copying your data, create an empty storage directory in any desired location. For example, if the location is /home/azureadmin, enter these commands:
sudo -s
cd /home/azureadmin
mkdir storage
Back up Moodle directories
In your on-premises environment, the moodle directory contains website HTML content. The moodledata directory contains Moodle website data.
Enter these commands to copy files from the moodle and moodledata directories into the storage directory:
cp -R /var/www/html/moodle /home/azureadmin/storage/
cp -R /var/moodledata /home/azureadmin/storage/
Back up PHP and web server configurations
To back up configuration files, follow these steps:
Enter these commands to create a new directory under your storage directory:
cd /home/azureadmin/storage mkdir configurationEnter these commands to copy the PHP and NGINX configuration files:
cp -R /etc/php /home/azureadmin/storage/configuration/ cp -R /etc/nginx /home/azureadmin/storage/configuration/The
phpdirectory stores PHP configuration files, such asphp-fpm.conf,php.ini,pool.d, andconf.d. Thenginxdirectory stores NGINX configurations, such asnginx.confandsites-enabled/dns.conf.
Back up the database
Follow these steps to back up your database:
Enter these commands to check whether mysql-client is installed:
sudo -s mysql -VIf mysql-client is installed, skip this step. Otherwise, enter this command to install mysql-client:
sudo apt-get install mysql-clientEnter this command to back up the database:
mysqldump -h <database server name> -u <database user ID> -p<database password> <database name> > /home/azureadmin/storage/database.sqlFor
<database server name>,<database user ID>,<database password>, and<database name>, use the values that your on-premises database uses.
Create an archive
Enter this command to create an archive file, storage.tar.gz, for your backup directory:
cd /home/azureadmin/ tar -zcvf storage.tar.gz storage
Download and install AzCopy
Enter the following commands to install AzCopy:
sudo -s
wget https://aka.ms/downloadazcopy-v10-linux
tar -xvf downloadazcopy-v10-linux
sudo rm /usr/bin/azcopy
sudo cp ./azcopy_linux_amd64_*/azcopy /usr/bin/
Copy archived files to Azure Blob Storage
Follow these steps to use AzCopy to copy archived on-premises files to Azure Blob Storage.
Generate a security token
To generate a shared access signature (SAS) token for AzCopy, follow these steps:
In the Azure portal, go to the page for the storage account you created earlier.
In the left panel, select Shared access signature.

Under Allowed resource types, select Container.
Under Start and expiry date/time, enter a start and end time for the SAS token.
Select Generate SAS and connection string.

Make a copy of the SAS token to use in later steps.
Create a container
Create a container in the storage account. You can either use the Azure CLI or the Azure portal for this step.
To use the Azure CLI, enter this command:
az storage container create --account-name <storage account name> --name <container name> --auth-mode loginAn example command is:
az storage container create --account-name onpremisesstorage --name migration --auth-mode loginWhen you use the
--auth-modeparameter with a value oflogin, Azure uses your credentials for authentication and then creates the container.To use the Azure portal to create the container, follow these steps:
In the portal, go to the page for the storage account you created earlier.
Select Container, and then select Add.
Enter a name for the container, and then select Create.

Copy the archive file to Azure Blob Storage
Enter this command to copy your archive file to the container that you created in Blob Storage:
sudo azcopy copy /home/azureadmin/storage.tar.gz 'https://<storage account name>.blob.core.windows.net/<container name>/<SAS token>'
An example command is:
azcopy copy /home/azureadmin/storage.tar.gz 'https://onpremisesstorage.blob.core.windows.net/migration/?sv=2019-12-12&ss='
Your Blob Storage account should now contain a copy of your archive.

Next steps
Continue to Moodle migration architecture and templates.
Povratne informacije
Pošalјite i prikažite povratne informacije za