WordPress Recovery

At some point of time, my dev notes for EnlivenVR suddenly stopped working, and I was devastated. However, today I was curious and try to revive it. I know the database is still there, and I can access the old site using FTP, so I try to remake the site, and somehow it works!

Before I forget, let’s write a note on it.

Here are the steps I took to recover the page, following this article:

  1. Back up old files from server using FTP. I’m not going to write about this. I use FileZilla FTP, since I’ve been using it for over 20 years, and it’s still working. Before that, I use WS FTP, but not sure what the status of that one nowadays.
  2. Back up the original database. I follow the steps from this site, but just in case the site goes kaput anytime soon, I will expand on this later.
  3. Create new database. Save the information, but leave it alone in the beginning.
  4. Download the latest WordPress files, and upload it to the server, on a new folder. Step 3 and 4 can be found in another note I wrote before. Don’t forget to modify the wp-config.php file before we upload, by adding database information from step 3.
  5. From my domain host, I create brand new subdomain just for the new site, and forward it to the new folder we created in step 4.
  6. Back to the database page, import the old blog database from step 2 into the new database we created in step 3. But before this, there are some modifications that I had to do, else we will encounter some issues on this portion. I will talk about the details later in this note.
  7. If we look at our old files from step one, look for wp-content/uploads folder. Upload this Upload folder to wp-content in the new page we add in step 4.
  8. Following my note on how to activate the new site, activate the site. In my case, it says the site is already active, and it asks me to log in. I don’t remember the password, but I can reset it. If you forget the username, open the original database file we downloaded in step 2, and there should be information of what username/email we use. I use this info and managed to create new password.
  9. After logging in, WP will ask to update the database. Hit OK, and the page should be ready to go.
  10. Since this time I get SSH, don’t forget to set it to https! Following this article, in WP, go to Settings > General and make sure that the WordPress Address (URL) and Site Address (URL) is https.

So, that’s it! After I have the site up and running, I noticed the template that I used before was no longer available. That was probably why the site suddenly stops working. So I install a different template and the website is up again. We will have to tinker with some setting like the widgets and menu too.

Database import issues:

Issue #1 – MySQL Error #1044

Blocks: it won’t let you import the file

Solution: I follow the advice from this article and removed the two lines about the old database information.


— Database: `oldDatabase`

CREATE DATABASE IF NOT EXISTS `oldDatabase` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `oldDatabase`;

— ——————————————————–

It still gave me issue afterward though. So I actually export the brand new database sql file, open it, and compare the content. I notice on the new database, the lines look as follow:


— Database: `newDatabase`

CREATE DATABASE IF NOT EXISTS `newDatabase` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `new Database`;
COMMIT;

— ——————————————————–

So instead of deleting the lines, I overwrite the lines. This solve the import error #1044. But then, I get into the next issue.

Issue #2: Some links still go to the old website, like the login page.

Blocks: Cannot access the new site, cannot even log in.

Solution: I went back into the modified old Database sql file that we just imported, and look for lines that have the old links, under wp_options, such as these:

(1, ‘siteurl’, ‘http://www.oldsite.com’, ‘yes’),
(2, ‘home’, ‘http://www.oldsite.com’, ‘yes’),

And replace the link to the new URL:

(1, ‘siteurl’, ‘https://www.newsite.com’, ‘yes’),
(2, ‘home’, ‘http://www.newsite.com’, ‘yes’),

This should fix the issue. Of course, then we get to the next issue as I try to import the updated database file.

Issue #3: MySQL Error #1050

Blocks: It says tables already exist, which, they do, from the previous import. It seems we can’t simply overwrite the changes this way.

Solution: Delete all the tables from this database. Don’t worry, since we still have the latest updated modified database on hand. After we start from empty database again, just like before, just import the database file, and it should load right away, with the correct links this time. I guess they call this process dropping the tables? [Article]

Try to log in and continue with installation, and the website should be up in no time~

Also, moral of this experience.. Please backup both your website files and the database often. I think I will also create a document copy of my notes from now on too, just in case even the database is corrupted.