In this article we will outline how you can transfer data from the Amazon Web Services (AWS) hosting platform to your InMotion Hosting hosting platform. This process requires the use of Command Line tools such as SSH and RSYNC. As such we only recommend doing this if you are comfortable with using a command line interface. Since this method requires the use of Linux commands, this process is best attempted in a Linux environment.
This guide will cover:
- Finding your AWS Username.
- Connecting to your AWS Instance via SSH.
- Dumping your MySQL database in AWS.
- Transferring data to your new server.
Transferring from AWS? Choose one of our Dedicated Server plans for the ultimate hosting experience.
Finding Your AWS Username
As you will need to know the username for the server instance you’re working on in order to connect, here is a list of common usernames and their respective Amazon Machine Images (AMI):
- Amazon Linux 2 or Amazon Linux AMI: ec2-user.
- CentOS AMI: centos.
- Debian AMI: admin or root.
- Fedora AMI: ec2-user or fedora.
- RHEL AMI: ec2-user or root.
- SUSE AMI: ec2-user or root.
- Ubuntu AMI: ubuntu.
Note: If ec2-user and root do not work, check with the AMI provider.
Connecting to your AWS Instance via SSH
- Log into your IMH Server via SSH.
- Create a working directory using the make directory command mkdir and change directory cd into it.
- Upload your .pem key pair file to the server into the working directory via SCP.
- Establish an SSH connection to the AWS instance using this command:
ssh -i /path/my-key-pair.pem ec2-user@ec2-198-51-100-1.compute-1.amazonaws.com
- You are now connected to your AWS instance via SSH and can begin running commands.
Note: The .pem key pair is generated when the instance is first created and the file should be saved in a secure location. If this file is lost, it is impossible to recover it and the instance will not be accessible.
Dumping your AWS Database Via SSH
Once you’ve established an SSH connection to your AWS server instance as outlined in the previous section, you can use MySQL commands to review the databases on the server and dump them into an .sql file that can be transferred to your new server:
Note: If you do not know the database username or password, you may need to first switch into the root user using the following command: sudo su root
- To see what databases exist on the server, run the command:
mysql -e SHOW DATABASES;
- Once you’ve determined which database you’d like to dump, you can use this command:
sudo mysqldump -u database_user -p database_name > database_name-backup.sql
The system will ask for a password at this point. If you’re logged in as the root user you don’t need one, so just hit enter until the command prompt returns. If you are not logged in as the root user, you will need to provide the database user password in order to proceed.
- You should now have a file on your server called “database_name-backup.sql”. Be sure to move this file using the move mv command to the same directory as your site files and then close the SSH connection to the AWS instance.
Note: If you are not using MySQL as your data storage solution, you will need to check the documentation for the software you are working with as the transfer process will likely differ.
Transferring Data from AWS Instance to InMotion Hosting Server
- Once back in the shell for your InMotion Hosting account, you can use SCP to begin the transfer of data using the following command:
scp - i /path/key.pem -r ec2-user@ec2-198-51-100-1.compute-1.amazonaws.com:/path/to/awsdata/ ~/home/user/newtransferdir
When connecting using this method you will need to ensure that you are in the same folder as the necessary .pem key file otherwise the connection will not work.
- To speed up the transfer process, you may want to create a .zip archive of the necessary data. You can do this via the following command:
zip -r "archive name" /path/to/files
- Alternatively, you can create a gzipped .tar archive using the following command:
tar -cfvz myfile.tar.gz mybackupdir
- Once the .zip or .tar archive has been created you can use SCP to transfer it to the new server as described in Step 1.
- Once the transfer process has finished you can close the SSH connection to the AWS instance and begin working with your data on the new server.
By following these steps, you will be able to successfully transfer site data, email data, or other software that may be stored on your AWS hosting service. Finding a new home for your data is just a few keystrokes away!