Question

I need help migrating my wordpress server

Posted July 12, 2021 87 views
WordPress

Some time back, I set up my wordpress server on an Ubuntu 19.10 droplet. Since support for 19.10 has been dropped, I need to migrate my installation to a new VPS. I have created a new droplet, installed wordpress on it, and backed up the database on the old VPS.

My challenges are as follows:

  1. How do I transfer my wp files over to the new server. I have read up about rsync, and scp, however, I am stuck when it comes to authenticating between the two servers. I currently use one SSH key to remote into both these servers. Is it possible to have multiple SSH keys and how do I generate them.
  2. Do I restore the database after the file transfer or before?

I am very new to all this, and had set up my wordpress website a long time back. I am however limited now as I cannot improve the functionality of my website without upgrading my server.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi @ak331,

Okay, so let’s start with your First problem, connecting between two Droplets. What you can do in this situation is generate an SSH key on the droplet you are migrating FROM and add the SSH key to the droplet you are migrating TO.

So, to do that, go to your old Droplet, the Ubuntu 19.10, SSH to it and type in:

ssh-keygen -t ed25519

Hit enter on all asked questions. Once you do, you’ll have an SSH key generated in the home directory of your user, if you executed the above command using root, you’ll have an SSH key in

/root/.ssh/

Now, copy the file idrsa.pub, it’s in the .ssh folder. You need to paste it on your New Droplet, inside “`/root/.ssh/authorizedhosts”`. If such a file doesn’t exist, create it. Once you paster the line, try to SSH you should be able to connect between the OLD and the New Droplet.

As for the second question,

After you’ve transferred the files, you can dump the database into a file from your old Droplet, rsync it to the new Droplet and import the database there.

When you are ready with migrating the files, type the following on your Old droplet to dump the database:

mysqldump NameOfDatabase > nameofdatabase.sql

This will dump the information of your database to the .SQL file. Now Rsync the file to the new Droplet. Once you do, you’ll need to import the .SQL file to a database you’ve created on the New Droplet. Before importing the database, create a database user which has privileges for the newly created database on your new Droplet.

Once you have this information, import the database like so:

mysql NameOfDatabase < nameofdatabase.sql

and that’s it.

Hope this helps a bit.