Migrating from bare metal servers to AWS
If you are looking to migrate data from your local Linux servers to AWS EC2 instances, then read on because this guide is for you. The steps required for this type of migration are split into sections and are discussed in order.
- Successfully deploy the infrastructure using the CloudFormation template. The Linux instances deployed on AWS will be where we will be migrating data to.
- Ensure that you have the credentials needed to access the AWS EC2 instance(s).
- You need to make sure that you have
ROOTaccess for both the source and destination server instances.
- Your SSH ports should be set to default (port 22).
- You must have
yum install -y screen).
You need to configure a temporary password-less configuration to achieve a connection from your source server to the destination server. You may achieve this using the following instructions:
Login to your local server and generate a public/private key pair if you don’t have one already.
ssh-keygen -t rsa
Use SSH to create an
.sshdirectory for the source server. This directory may already exist, so if you are sure it does, you may skip this step.
ssh user@EC2IP mkdir -p .ssh
Finally, append the public key of your local server to the EC2 server.
cat .ssh/id_rsa.pub | ssh user@EC2IP 'cat >> .ssh/authorized_keys'
Verify the password-less SSH by trying to connect to it.
To help us with migrating resources, we will be running a script.
It is recommended to install
screen on the source server so that we can maintain a persistent session during this
potentially long process. You may use your package manager to perform the installation.
We start by launching a
screensession with the command:
screen -S OCSMigration
In case you get disconnected, you can run this command to resume the session after logging back in:
Now it is time to retrieve the script. You may retrieve it via:
Make sure it is executable by running the following command:
chmod +x rsyncmigration.sh
Once you are able to retrieve the script, you may now execute it by running:
This script will:
- Prompt you for the IP address of the target server.
Ask you which directories you would like to migrate. It will ask you the path of the following directories:
Afterwards, the script will attempt to connect with the destination server as
- After that it will ask you to specify your organization name. This name is relative to the path which was
created for you during the CloudFormation setup. The syntax goes as follows:
- It will also ask you to verify the path, and to ensure it exists in the destination server as there is no way to check if the directory exists or not.
- After authentication, the script will attempt to setup a key-based authentication between the source and destination server. Make sure that your SSH port is 22, at least for the migration.
- The script will attempt to verify the installation of
rsyncon both servers.
- It will run
rsynctwice. First, to attempt to migrate the data; and second to perform a final sweep in an attempt to follow up on any missed files or files that may have had changes during the first sync.
After the process has ended, verify if the files have been successfully migrated. Once verified, you may now use this data for your TORO Integrate instance.