Migrate wordpress site manually

After a quick search to look for some information about how to migrate a wordpress site manually I realised that most of the solutions used some plugins. I like to do things in the hard way, so I decided to migrate all data manually and I want to share all the steps I did just in case someone finds them useful.

The goal of this entry is just to detail the steps needed to migrate the wordpress site from one host to another one. I won´t describe how to install wordpress in the new host.

I migrated my wordpress site from a VM running in Hetzner to another VM running in Oracle Cloud (both VMs running the same version of OS).

Requirements

  • WordPress is running same version in both VMs
  • MySQL is running the same version in both VMs
  • PHP is running same version in both VMs
  • Apache2 is running same verion in both VMs

Steps in the source VM

  • Stop apache2 server
systemctl stop apache2
  • Create a backup of the database
mysqldump -u root --database <wordpress_database> -p > wordpress_dump.sql

The above command will ask your for the password of the root user of the MySQL instance. Bear in mind you need to replace <wordpress_database> by the name of the database configured in wordpress.

  • Compress the folder where the wordpress site installation is located. In my case, it is /var/www/wordpress
tar cfz wordpress.tar.gz /var/www/wordpress
  • Copy wordpress_dump.sql file and wordpress site tar file to the destination VM
scp wordpress_dump.sql <user>@<vm_destination_ip>:
scp wordpress.tar.gz <user>@<vm_destination_ip>:

Bear in mind that <user> and <vm_destination_ip> must be replaced

Steps in the destination VM

  • Connect to MySQL instance, create the db, create the wordpress user and grant the required permissions
mysql -u root -p
CREATE DATABASE wordpress;
CREATE USER wordpress@localhost IDENTIFIED BY '<PASSWORD>';
GRANTS ALL PRIVILEGES ON wordpress.* TO wordpress@localhost;
  • Import all the data into the database
mysql -u root -p wordpress < wordpress_dump.sql
  • Copy the wordpress site files to the desired path
tar xfz wordpress.tar.gz
cp -R wordress /var/www
  • Enable the required plugins in apache2
a2enmod ssl
a2enmod rewrite
  • Restart apache
systemctl restart apache2

I hope you find useful these steps. Do not hesitate to ask any question in the comments section.

See you in the next post!

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *