Migrating to MDOQ is easier then you might think! This guide will take you through the process of creating/setting up a production instance (production site) on MDOQ.
We are always working on improving the process if you have any suggestions please get in touch.
Before beginning this process you will need to have a production account set up within MDOQ, if you're unsure don't hesitate to contact us.
N.B if you are migrating an existing site that is already set up in MDOQ as a live connector the backups, please reach out to us, as we can copy backups and settings across to your new production site without the need for the steps below.
Prerequisites
To be able to migrate a site to MDOQ hosting you will need the following:
- Ability to SSH into your current webserver as a user that has access to both the file system and the database
- Ability to SSH into your current webserver and install a cli package
The following aren't mandatory but are nice to have, we can of course assist you with setting these up.
- Code base should be in source control with Github or Bitbucket
Instructions
1. Code Backup
The first step is to generate a code backup of your site. This backup should be the code base, excluding media.
- SSH into your webserver
- Change directory to the web root, and change user to the Magento web user.
- Create a .tgz of the code base
php bin/magento setup:backup --code
This will create a code backup in the "var/backups" directory
2. Database Backup
Next we need a database backup.
- SSH into your webserver
- Change directory to the web root, and change user to the Magento web user.
- Create .sql.gz of the database
php bin/magento setup:backup --db
This will create a db backup in the "var/backups" directory - You will then need to compress this backup
gzip path/to/backup
for examplegzip var/backups/1634286600_db.sql
3. Installing the MDOQ CLI
The easiest way to send backups to MDOQ is to use MDOQ CLI, instructions on installation and configuration can be found here
4. Pushing backups to MDOQ
To push backups using the MDOQ CLI you will need to know the ID of your production instance.
Pushing the code backup
mdoq backups:push --instance-id=INSTANCE_ID --backup-type=code-backup --file=/path/to/backup.tgz
Pushing the db backup
mdoq backups:push --instance-id=INSTANCE_ID --backup-type=full-db-backup --file=/path/to/backup.sql.gz
Once both these have pushed you can verify they are in MDOQ by:
- selecting your production instance
- clicking "toolbelt" > "snapshots"
- Then clicking "manage" on each backup type to validate the backups are there.
5. Configuring Source Control
If you don't have source control or your source control provider isn't in the list below please get in touch.
6. Service Configuration
To ensure MDOQ provisions the correct infrastructure for you site we need to configure the correct service versions of your site.
Please obtain a list of all service versions you are using.
Once you have this list
- Log into MDOQ
- Select your production instance
- Select "Settings"
- Change the versions for each service as appropriate
- click save
7. Roll up site
- Log into MDOQ
- Select your production instance
- Select "Sync"
- Click "Show More"
- Check every box
- Click "Proceed"
8. Uploading Media
Before uploading media, you need to make sure you have configured ssh access to the new MDOQ production instance. To do this please generate and SSH key on your current server (where the media files are located) with a name like `~/.ssh/mdoq'
You will then need to add this key to MDOQ named something like "old server"
A guide on configuring SSH and generating SSH keys can be found here
Once you have configured SSH access it's easy to set the connection to MDOQ up as a named host. (It makes the rsync command much simpler)
On the old server update/create the file "~/.ssh/config" with the following. Replacing the bracketed values with the credentials for your instance.
Host mdoq
User magento
Hostname [instance hostname]
Port [instance port]
IdentityFile [path to private part of ssh key pair]
You should then be able to run
ssh mdoq
From the current server.
If this doesn't work it will need to be resolved before proceeding
You can then sync media to your MDOQ production site with the following command. (Replace the path the media directory)
rsync -anv /path/to/pub/media/ mdoq:/home/magento/htdocs/pub/media
N.B it is very important that you don't have trailing slashes at the end of the directory paths
If the output looks correct you can do the actual rsync by removing the dry run flags
rsync -a /path/to/pub/media/ mdoq:/home/magento/htdocs/pub/media
If you want a more verbose output you can run
rsync -av /path/to/pub/media/ mdoq:/home/magento/htdocs/pub/media
If you are going to be running the existing server for a little while, whilst you migrate to MDOQ we recommend setting up a crontab entry to sync the media directory, something like this should suffice
0 * * * * rsync -a /path/to/pub/media/ mdoq:/home/magento/htdocs/pub/media
9. Post Install Checklist
At this point the production site should be up and running.
There are a few common tasks and question that you may wish to carryout / ask.
Please see the Post Install Checklist
Final Migration
Once you're happy with your new Production site, please see Final Migration for how to finish off the migration to MDOQ Hosting.