My site now lives on a newly built NAS

My site is now hosted by a new DS-1520+ server I’ve brought online. In the process I’ve figured out how to move a wordpress site. The steps fell into place pretty smoothly until right near the end when I tried to restore my wordpress database backup and could not! Ultimately I figured out a workaround for that and hence you’re viewing this page from the site’s new home 🙂

I’m capturing the process I followed here. In my case the old server and new server are both a flavor of linux (Synology DSM) and the database gets managed by phpMyAdmin.

The steps I followed include:

Backup Web Site

  • Backup Database. In phpMyAdmin I did a simple quick-export of my wordpress site’s database and saved the .sql file for later.
  • Backup WordPress Files. At about the same time as the SQL backup, I also made a copy of all the files the make up the web site starting with the top-level directory where wp-config.php is found for example.

Prepare Web Server

  • Redirect misguided or unsecure URLs. In my case the server was brand-new and would return an empty home page but that’s about it. Something I try to manage outside of any specific web site on my server, is redirection of HTTP to HTTPS. And in the same breath, redirection of www.<site> to just <site>. This way I don’t have to build that logic into every web site. So with that in mind I deployed a top-level .htaccess file that will do the redirections without any logic in the virtual host itself.
  • Configure PHP and Apache backends. As part of setting up the virtual host tell it which version of Apache to run (2.4 as of this writing) and which PHP version (7.4 as of this writing). Also the PHP options/capabilities need to include what the site needs – I just copied the settings from the source to destination servers.
  • Setup Web Container and Security Certificate. Setup the web server to recognize the hostname on the incoming request and route it to the correct web site. In my case that includes setting up a Virtual Host that maps walterstovall.online to my web site’s files. I also exported the walterstovall.online security certificate and then imported at the new server, associating the security certificate with the walterstovall.online virtual host (seeing how computers have to be told everything).

Restore Backup and Test Site

  • Import database. Create a new database with utf character set. Import the .sql file backed up from the site earlier. This failed for me! See workaround below…
  • Copy backup of web site files. Deploy the backup of files. But also edit wp-config.php to enter correct new database password and new hash keys – see the steps taken here with regard to editing the file if you’re not sure what to do. Then be sure and setup file attributes so the site is secure.
  • Modify the hosts file in your C:\Windows\System32\drivers\etc so you can point your computer to the new site, while the public is still routed to the working installation. Now try to launch your site. Once you’re happy with the operation, reconfigure your DNS to point to the new IP and let the good times roll!

What if it doesn’t work??

You’ll have to debug it :-(. In my case everything went smooth till I tried to import that database backup. That failed with a SQL error bringing in one of the Wordfence tables. I don’t know if this is a Wordfence bug or something corrupt in my database/schema/?. Restoring a backup to the original server would fail in the same way.

If I ignored the error, the site would actually function except it would not let me login! Ultimately I got around it by doing the following:

  • Deactivate the Wordfence plugin and backup the site again.
  • Choose the Advanced option at Export in phpMyAdmin and deselect the wpwf* database tables when making the export.
  • Now deploy backup files as-above. This time the import works without the problematic Wordfence table present.

Leave a Comment