Pages

Thursday, January 6, 2022

Rescuing a WordPress-based site on Amazon LightSail and moving to another VPS

Don't get me wrong, Amazon LightSail is one of the most affordable VPS services out there.  A big name such as Amazon might give you the feeling of stability, reliability, and so forth. I have no complaint at all so far as my clients are happy with that.

Yet, they still want to move the servers closer to their customers, and given that Amazon is still not available in Vietnam yet, it becomes a new mission. Turn out the limitation of the VPS in terms of CPU and RAM might give me another kind of headache. Normally, I have no problem with moving the site to a new server especially in the case of WordPress as there are tons of already-built plugins on the market.

So "rescuing" in this post simply means it seems impossible to backup a WordPress with a limited source VPS (say 1GB of RAM).

Here are the defined steps I often do to clone and move a WordPress-based website using the Duplicator plugin.

1) Updating WordPress and all active plugins. Remove inactive ones.

2) Clone the current site using Duplicator.

3) Upload the package issued by Duplicator on a brand new VPS and then run installer.php (this file is given by Duplicator). During this process, you will have to create a new database on the new VPS.

4) Make some changes if needed.

However, the above process does not work well as Duplicator cannot clone the whole website when the RAM of the current VPS is limited. And this time it hurt me badly.


Here are what I did to handle it.

1) Cloned the current VPS on LightSail using the snapshot feature and then restored on a new computer with higher resources (4GB of RAM for example).

2) Run Duplicator. This time it worked

3) Following the above steps to restore the package given by Duplicator.

4) Check the site and then change DNS on Cloudflare.

5) Check new DNS via https://check-host.net/ or https://dnschecker.org/

6) Note: for those who are using aapanel, you might need to fix the 404 error as nginx does not handle the .htaccess file. 

location / {

    # file ($uri) or directory ($uri/)? if not, redirect to /index.php + query string

    try_files $uri $uri/ /index.php?$args;

    index  index.html index.htm index.php;

}

Take a look at the following image:

FYI: In case you use Plesk, then you might take advantage of the Migration feature which allows you to clone and restore your server to another one in a few minutes. I might write another post about that.