In Part 1, we prepared for the migration by creating backups, checking the server requirements, and making sure we had everything we needed.
In this guide,we will take the website files and database from the old server and restore them on the new server.
The old website will remain online while we prepare the new server.
A typical website migration involves moving two main things:
These may include:
The database usually contains things such as:
For a WordPress website, both the files and database are required.
Moving only the files will not give you a complete copy of the website.
There are several ways to move files between servers.
One simple option is SCP, which securely copies files between Linux servers.
From the old server, you can run:
Let's break this down.
scp — securely copies fileswebsite-backup.tar.gz — the backup we created in Part 1username — your new server usernameNEW_SERVER_IP — the IP address of the new server/home/username/ — where the backup will be placedFor example:
You will normally be asked for the password of the destination server.
Once the transfer finishes, log in to the new server and check that the file exists:
If the backup appears, the file has successfully arrived on the new server.
If you are moving a large website, rsync can be a better option.
For example:
One advantage of rsync is that it can copy only files that need to be transferred, which can make repeated migrations or transfers more efficient.
For this guide, however, we will continue using the backup archive because it keeps the process simple.
Now connect to the new server using SSH.
For example:
Once connected, go to the directory where you uploaded the backup:
Extract the backup:
This will recreate the website files from the archive.
If the backup contains public_html, you may now have:
Check the contents:
For WordPress, you should see files and directories such as:
At this point, the website files are on the new server.
The next step is to recreate the website database.
If you are using cPanel, go to:
cPanel → MySQL Databases
Create:
Then add the user to the database and give it the required privileges.
For example:
Keep these details safe.
We will need them when connecting the website to the new database.
Remember the database-backup.sql file we created in Part 1?
Now we need to import it into the new database.
If the SQL file is already on the new server, you can use:
For example:
Enter the database password when prompted.
If the command finishes without an error, your database should now be restored.
The website needs to know where its new database is located.
For WordPress, open:
You can edit it using:
Look for:
Change the database details to the ones you created on the new server:
Save the file.
Important: Never publish your real database password in screenshots, tutorials, or public repositories.
Your files may now be in the correct location, but the server also needs permission to access them.
First, check the ownership:
If necessary, ownership can be corrected.
For example:
However, permissions vary depending on your server configuration.
If you are using cPanel, avoid changing permissions unnecessarily. The hosting environment may already have the correct ownership and permissions configured.
Do not change your DNS yet.
The new server should be tested first.
Depending on your setup, you can test the website using:
Check the important parts of the website:
If it is an online store, test the important shopping and checkout functionality as well.
The goal is to make sure the website works on the new server before visitors are sent there.
If you see:
check:
A 403 error may be related to:
.htaccessCheck the server configuration before making major permission changes.
A 500 error can happen when the new server uses a different:
.htaccess configurationChecking the server error logs is usually the best way to identify the cause.
At the end of Part 2, we should have:
Most importantly, the old website is still online.
We have prepared the new server without changing where the domain currently points.
In Part 3, we will take the website live on the new server.
We will cover:
This is the stage where we finally point the domain to the new server.
How I Migrated a Website to a New Server – Part 3: Testing, DNS & Going Live
Your email address will not be published. Required fields are marked *
Comments