Follow the steps below to migrate to AMIMOTO HVM Version (corresponding t2.micro, t2.small, t2.medium) to the new instance of AWS EC2 T2 family instance that you created in the AMIMOTO PVM Version.
In addition, please note that it cannot respond to changes from the EC2 Dashboard “instance type” because the AMI ID is different between HVM and PVM version.
1. Create an instance with AMIMOTO (HVM Version)
Create a new instance in AMIMOTO (HVM Version). Please refer to the guide on “How to use” for further details. If you want to use (t2.micro, t2.small, t2.medium) the T2 family VPC you need to create an instance in that environment.
Boot-up is the complete installation screen of WordPress that you could check and try to access a Public IP from an instance after starting the browser. At this point, however, do not try to install WordPress yet.
2. EIP for a new instance assignment
To access SSH into a new instance, you were given an EIP. In “EIP used in:” please select “VPC.”
Carry out the same setting as the old instance if required
At this stage, please create Nginx and users must change the password for the root user.
Also, if you have installed multiple virtual hosts in the former instance WordPress wp-setup
, please make sure that you create the same virtual host to the new instance previously made with the command.
If you use this, modify the configuration file of nginx because it is also necessary in a new instance of the WordPress multi-site.
The set up of the new instance will start at this point.
4. Export the old instance database
It is recommended the you keep a snapshot of the old instance you worked on before.
After moving to the directory in which you connect with ssh to the old instance, you have installed WordPress, WP db export
to export the database.
$ cd /var/www/vhosts/{Instance ID or Virturl Host Domain}/
$ wp db export
The Sql file written is the same as WordPress now.
5. rsync data migration
You have to copy the .pem file of the old instance to the new instance/ home/EC2-user/
(You can copy the SFTP client).
SSH into the new instance copy of the key file when you are finished.
You have to move to the root directory of the ec2-user so they will not be overwritten by the file of the old instance wp-config.php
of next new instance.
$ cp /var/www/vhosts/{Instance ID or Virturl Host Domain}/wp-config.php ~ /
Then I copied rsync
into the new instance data of the old instance in the command.
$ sudo rsync -avz --delete -e 'ssh -i hoge.pem' ec2-user@{old_server ip}:/var/www/vhosts/{old_instance id}/ /var/www/vhosts/{new_instance id}/
old_server ip
, the IP address of the old instance
hoge.pem
is the .pem file of the old instance that you just copied earlier.
Old_instance id
, the virtual host name (or the instance name of WordPress directory of the old instance to new_instance id
. Please put the virtual host name (or the instance name of WordPress directory of the new instance. Please note that this part is the same in the case of virtual host).
File copy begins,
sent 444747 bytes received 123553640 bytes 9919870.96 bytes / sec
total size is 184523184 speedup is 1.49
The complete display will appear.
At this time, the sql file that was extracted before will also be copied /var/www/vhosts/{id} New_instance/
. Make sure that it is copied correctly.
Lastly, save wp-config.php
to restore.
$ Sudo cp ~/wp-config.php /var/www/vhosts/{new_instance id}/
6.Import the database to the new instance
Import the database to a new instance.
Navigate to the installation directory of WordPress,
$ Wp db import {wordpress.sql}
Run the wordpress.sql
(this is the name of the sql file exported).
Import after the completion of the database, even if you have assigned a unique domain or virtual host, you can check the transition to the DNS before switching by adding write (domain) new IP address and host name to the hosts file on your machine .
If you are sure, you may delete the unnecessary data such as sql file in the new instance.
※ Please repeat steps 4-6 if you have installed the WordPress multiple virtual host.
7. Rewriting of DNS
Once you’ve checked the hosts files rewrite, switch the server name display in the new instance.
Replace the IP address to the new instance the IP address listed in the A record for the domain. Set the server name to:
$ Dig example.com
Confirm.
Once you have the confirmation, return to the original hosts file that was rewritten switching the server name.
8. Stop the old instance
Once the server name is switched, terminate the old instance. Select the instance to be that you want to stop by clicking “Terminate” under the “Actions” drop-down menu.
Don’t forget to check the box to completely terminate the IP address that was linked to the old instance.
※ The IP address that was acquired in Elastic IPs is not linked to the server instance and will be charged $5/month.
Delete the instances if necessary, including the snapshot of the old instance.