On manual WordPress migration after domain transfer

I have recently moved the gencoded.com domain to a new hosting provider. In that process, I naively expected that, having backed up my WordPress site, moving the site to its new home will be just a breeze. Couldn’t be more wrong. The back-ups were performed regularly using one of the WP plugins and so I imagined the restoration process will only take clicking the ‘Restore‘ button, while enjoying a cup of coffee. Unfortunately, it was slightly more complicated. For the sake of documenting the process I decided to write this short post on manual WordPress migration, summing up the steps that were required to restore the site with its full functionality, should anyone encounter a similar problem or should I myself run into this ever again in the future.

Before we start

Just a small note: we will start from the end – I am first going to describe how the site was restored and then reflect a bit on the actual process of preparing the backups. Sit tight!

Restoring the site

Configure fresh WP installation

To restore the site after the domain move, you first need a fresh WP installation on your domain:

  1. Create a new, empty WordPress site (same domain name!). Creating it with the same admin user will make the whole process a bit easier.
  2. If not automatically configured, create an FTP user with read/write access rights to the site’s directory.
  3. The same applies to the MySQL database connected to the site: a user with write permissions will be required.

Copy backed-up files

After setting up all the access, we need to copy the site’s data and restore contents of the SQL database:

  1. Using an FTP client (or any other way) replace the img and wp-contents directories in your fresh installation of the site with the ones from your backup.
  2. Copy the entire contents of the backed-up SQL database into your new database: most likely the names of the tables will have a different prefix in the old and new installation so there should be no conflicts.

Restore connection to the DB

Adjust the wp-config.php to recognise the new copied SQL tables – this should only require you to change the table prefix on the following line:
$table_prefix = 'wp_123456_';

Simply replace the new prefix (here represented by wp_123456) by the prefix from your backed up database.

It could happen that you will encounter an issue with password recognition during log in after having done the described changes. This is due to the old password being saved in the old database and that password not being the same as the one of the new WordPress installation. To circumvent this problem, you can simply copy the password from the new users table to the one you reverted from the backup. You will find the password in the user_pass column.

That’s it! Your site should now be functional.

The only issue I had with that approach was that one of the plugins had some trouble connecting to the database. Simply re-installing that plugin solved the problem.

Thoughts on creating the backup

Having gone through the process described above, I feel like backing up the site “manually” is not such a big deal after all. Yes, using plugins designed for that makes the process much easier with the added benefit of easy scheduling. However, I am going to try to perform a couple of “manual” backups using the approach described below. Just a warning: it’s more of a concept for now, and a very crude one so use with caution 😀

  1. Make a copy of the entire site FTP directory using wget:
				
					wget -r --ask-password ftp://ftp_user@ftp_host
				
			
  1. Make a copy of the entire SQL database using mysqldump :
				
					mysqldump -v --user=db_user --host=db_host db_table > backup.sql
				
			
Note: you can get mysqldump tool as part of the mysql-client on MacOS by doing:
				
					brew install mysql-client
				
			

If you are still interested in checking out some plugins for backing up your site, here are some examples:

That’s all for this post. I do hope I will not need to do any restoring in the nearest future but in case it ever happens again, it should (at least theoretically) be much less painful than the first time.

 

Leave a Reply