Site Migration

Migration process is divided into following parts

  1. Setup Server
  2. Create Website
  3. Copy Web-root
  4. Import Database
  5. DNS

NOTE: We used the 1.1.1.1 as old server ip-address and 2.2.2.2 as new server ip-address in this article you need to change this values.

Setup Server

First log in to new server and install EasyEngine

wget -qO ee rt.cx/ee && sudo bash ee
ee stack install

Above two commands install all the dependency and EasyEngine.

Create Website

By default, EasyEngine automatically created database, MySQL user/password for the domain name like example_com

We can simply force EasyEngine to ask us for the database, MySQL user/pass so we can used same credential we used in old server to avoid manual modification in  wp-config.php file.

Lets modify the /etc/easyengine/ee.conf file to avoid later manual work 🙂

vim /etc/ee/ee.conf

and set following values

# Custom Database Name
db-name = True
# Custom Database User
db-user = True

Lets create a example.com on new server

ee site create example.com --wp

It will output as follows

Creating example.com, Please Wait...
Creating Symbolic Link For example.com
Creating htdocs & logs Directory
Creating Symbolic Link For Logs
Downloading WordPress, Please Wait...
Enter The MySQL Database Name [example_com]: example.com
Enter The MySQL Database Username [example_com]: exampleuser
Enter The MySQL Database Password [73kWK4MpRiXjuvo]: mypass

Setting Up WordPress, Please Wait...
Updating WordPress Permalink, Please Wait...
Installing Nginx Helper Plugin, Please Wait...
Changing Ownership
Reloading Nginx Configuration, Please Wait...
Take /etc/nginx 
Configuration In Git Version Control...

WordPress Admin Username: admin
WordPress Admin Password: HelloExample
Successfully Created New Website: http://example.com

Copy Webroot

Now example.com is ready on new server but we still need old server data

Lets copy the web-root from old server to the new server

cd /var/www/example.com/htdocs
rm -rf *
rsync -avz --progress root@1.1.1.1:/var/www/example.com/htdocs/* .

Note: do not forget the “.” dot at the end.

Now we copy the web-root from old server to the new server.

Import Database

Take mysqldump on old server

mysqldump -u root -p example.com > /tmp/example.com.sql

Lets copy and import the MySQL dump on new server

rsync -avz --progress root@1.2.3.4:/tmp/example.com.sql /tmp
pv /tmp/example.com.sql | mysql example.com

As of now we have same web-root and database as old server.

Point DNS

Lets test the site before pointing DNS

You need to modify your local system /etc/hosts file

vim /etc/hosts

and add following line into it

2.2.2.2 example.com www.example.com

Lets open example.com in your web-browser to test and if all looks good point DNS to the new server ip-address.

As per our roadmap the EasyEngine Migration Release do all the above stuff with single command like

ee site copy old-server-ip new-server-ip

 NOTE:  This feature is not yet completed

Leave a Reply