This tutorial will cover the steps needed to migrate a cloud server from cloud hosting providers such as Amazon Web Services, DigitalOcean, Linode and Rackspace to a Kyup container using our auto-migration script.

To use it, you’ll first need to make sure that your cloud server is based on Linux and choose an appropriate time when it won’t be an issue to stop your database, apps and processes on your existing cloud server, until the process is completed. The transfer runtime depends on the size of your virtual machine and may vary between a couple of minutes to about an hour.

Launch a plain Kyup container

In order to start with the migration of your Linux-based cloud server, you need to launch a new container. (if you don’t know how to do that, here is a handy step-by-step guide: How to Create your First Container)

On the Configuration step of the launch process, select “Migrate an existing cloud server”. You will see the Plain container image option pre-selected by default.

You will also have the option to request a professional server migration. This means that our tech agents will perform the migration for you and you won’t need to run our script yourself. If you prefer this option, simply check the Request professional migration radio button. If not and you would still like to run our script yourself, leave it unchecked and continue reading below.

During the creation process you have the option to install one of the existing SSH keys in your account to your container. If you don’t have any keys created, you can always add one later. You will need to do this, in order to be able to access the container via SSH and run our script from there.

When all of the information is filled you should press the “Launch Container” button and your plain container will be up and running in 5 seconds.

Create a migration configuration file

Once you have your new container ready, you should SSH into it. Detailed information about how to SSH to your container is available in the How to SSH to your container on Linux tutorial.

The newly created container is a plain Linux-based OS image with only a few basic commands.

For this migration you should create one configuration ( migration.cfg) file which should contain the information that will be used for the migration process.

The mandatory configuration options in the migration.cfg are remote_ip, container_ip and remote_password or key. The optional configuration options are remote_user and remote_port, which by default are set to: remote_user=root and remote_port=22.

Please note that all of the configuration options should be on a separate line and there should be no space character before or after the equal sign "=" when the configuration options are typed. The correct spelling is option=value and incorrect is option = value.

The remote_ip is the external public IP of the Linux-based OS virtual server you'll be migrating.

The container_ip is the Kyup container IP of the container that you are logged in (Available in the Containers page in your Kyup User Area ).

The key is a string value. It specifies if you will be using key authentication for loggin in the remote Cloud server. If it is set to kеy=1 - it is enabled. If the key option is not added to the configuration it is disabled and you should specify remote_password value, in order to access the remote server using password authentication.

Migrate using root user and password

In this example, all of the commands below should be executed from your Kyup container's /root/ directory.

After you are logged in to the Kyup container, verify that you are able to ssh with user root and its password to the remote Cloud server:

Once you verify that the connection is successful, you can proceed with the next step - creating the “migration.cfg” file. To do so, you can use the “cat” command. When all of the configuration options are entered press and as it is showed at the example below. Please note that the password should be enclosed in single quotes:

Press <ENTER> and <Ctrl+D>

Verify that the migration.cfg files contains the required configuration options:

Please note that before starting the script that will migrate the Cloud server to a Kyup container, you should verify that all applications and all databases are stopped in order to avoid any data inconsistency after the migration.

In order to start the migration you will need to run the script ./sync_from_VM.sh which will use the migration.cfg as a configuration file.

Depending on the size of the server being migrated, the script might take from couple of minutes to few hours. Please, make sure you leave it running and your applications and databases remain stopped during the whole process until you see a message confirming the migrations has been finished. Otherwise, the process will not be completed entirely and successfully.

When the script finishes, it will automatically reboot your container. Once it’s back up, it should have all the information from your Cloud server. The only difference will be the IP address of the server.

Migrate using root user and SSH key-pair

In this example all of the commands below should be executed from your Kyup container's /root/ directory.

In order to perform a migration with ssh key pair, the cloud server being migrated should have the public part of the key pair placed in /root/.ssh/authorized_keys file. This could vary, however, depending on the SSH setup on your Cloud server.

The ssh private key which will be used for the migration should be placed in the ~/.ssh/client_key file of the newly created container on Kyup. In order to add the private ssh key please follow the steps below:

Connect via SSH to the newly created container. You should use the cat command to create ~/.ssh/client_key file and add the ssh private key in it. When the ssh key is typed press <Enter> and <Ctrl+D> as it is demonstrated in the example below:

Copy or type the private key and press <ENTER> and <Ctrl+D>

Verify that the “.ssh/client_key” files contain the ssh private key:

Since this ~/.ssh/client_key file is ssh private key the permissions of the file should be read only by the user:

Verify that the ssh connection from your Kyup container to the remote Cloud server is successful:

The next step is to create the migration.cfg file. To do so, you can use the “cat” command. When all of the configuration options are typed press <Enter> and <Ctrl+D> as it is demonstrated in the example below:

Press <ENTER> and <Ctrl+D>

Verify that the migration.cfg file contains the required configuration options:

Please note that before starting the script that will migrate the virtual server to a Kyup container, you should verify that all applications and all databases are stopped in order to avoid any data inconsistency after the migration.

In order to start the migration you will need to run the script ./sync_from_VM.sh which will use the migration.cfg as a configuration fail.

Depending on the size of the server being migrated, the script might take from couple of minutes to few hours. Please, make sure you leave it running and your applications and databases remain stopped during the whole process, until you see a message confirming that the migration has been finished. Otherwise, the process will not be completed entirely and successfully.

When the script finishes, it will automatically reboot your container. Once it’s back up, it should have all the information from your Cloud server. The only difference will be the IP address of the server.

Migrate using SSH key-pair, non-standard user and SSH port

In this example, all of the commands below should be executed from your Kyup container's /root/ directory.

The user that will be used in this example should have the same privileges as the root user on the remote cloud server, as well as a full access to all files and directories, since we are migrating everything from the root folder (/).

In order to perform a migration with ssh key pair, the remote cloud server being migrated should have the public part of the key pair placed in /root/.ssh/authorized_keys file. This could vary, however, depending on the SSH setup on your cloud server.

The ssh private key which will be used for the migration should be placed in the ~/.ssh/client_key file of the newly created container on Kyup. In order to add the private ssh key please follow the steps below:

Connect via SSH to the newly created container. You can use the cat command to create ~/.ssh/client_key file and add the ssh private key in it. When the ssh key is typed press <Enter> and <Ctrl+D> as it is demonstrated in the example below:

Copy or type the private key and press <ENTER> and <Ctrl+D>

Verify that the “.ssh/client_key” files contain the ssh private key:

Since this ~/.ssh/client_key file is ssh private key the permissions of the file should be read only by the user:

Verify that the ssh connection from your Kyup container to the remote cloud server is successful:

The next step is to create the migration.cfg file. To do so, you can use the “cat” command. When all of the configuration options are typed press <Enter> and <Ctrl+D> as it is demonstrated in the example below:

Press <ENTER> and <Ctrl+D>

The remote_port option defines the port number on the remote Cloud server the SSH service listens to. The remote_user option defines the username of remote privileged system user. This user should has the same privileges as of a root system user.

Verify that the migration.cfg files contains the required configuration options:

Please note that before starting the script that will migrate the remote Cloud server to a Kyup container, you should verify that all applications and all databases are stopped in order to avoid any data inconsistency after the migration.

Run the script ./sync_from_VM.sh which will use the migration.cfg as a configuration fail.

Depending on the size of the server being migrated, the script might take from couple of minutes to few hours. Please, make sure you leave it running and your applications and databases remain stopped during the whole process until you see a message confirming that the migration has been finished. Otherwise, the process will not be completed entirely and successfully.

When the script finishes, it will automatically reboot your container. Once it’s back up, it should have all your information from your Cloud server. The only difference will be the IP address of the server.

So far we’ve tested the script for CentOS 6.6, Debian Wheezy or Ubuntu 14.04/12.04 distributions. It should be working the same way on any other Linux distribution. If you find a use case where the script does not work properly, please let us know, so that we can look into it.