Having restoring from backup in mind
Most people doing any kind of work on a computer have in their minds that there is a need to backup files, but don’t really give proper thought to what circumstances they may need to reinstall from their backup. I think about it, but don’t get round to acting on this thought often enough, until there is an issue. I had a wake up call recently that has made me take some action and write this post.
Real life site down nightmare example
I received an email about a WordPress website that I created about 6 months ago for a friend as a portfolio for his art. The message said there was something wrong and that the site was down. The message was from someone trying to look at the site not the person whose site it was. It turned out that the company that the domain registration was with had stopped doing web-hosting and had sent a few emails that had been ignored with a deadline to transfer the files elsewhere, after which time they would no longer be accessible.
The initial investigation showed me that it was still possible to log on to the company’s control panel and details about the domain registration and the access to name servers and DNS records was still present, but no access to the control panel for the MySQL database or the WordPress files. Next I tried the ftp programme that I use (FireFTP) and I was still able to connect to the server with the files. So straight away I downloaded everything there into a folder on my computer, just in case. But that is only the collection of PHP files that make up WordPress, not the MySQL database that holds all of the text and settings content. Luckily I had a backup of the database, but it was out of date, changes had been made since. However it was the best I could do.
Possible occasions to need to restore WordPress from backup
These are a few reasons I can think of, off the top of my head:
- Need to transfer to a new host
- Have added a plugin that has messed up the site
- Have done an update that has messed up the site
- Have done some changes yourself that has messed up the site
- The site has been hacked
What you need to do to restore from backup to a new host
This is a record of what I did to successfully restore the site omitting the wrong turns. It’s not necessarily the only or best way, but it is a record for myself in case I need to do it again sometime.
- Find/download the most recent backup of the MySQL database
- Find/download the most recent WordPress files
- Install a new blank WordPress site (in the same folder arrangement as previous site eg domain.com/blog)
- Update WordPress to the latest version
- Open MyPHP control panel for the new database created from the new WordPress installation
- Import into the MySQL database from the database backup
- In File Manager on the new install host or using FTP move wp-content and wp-includes folders (and content) to another directory (name it temp or something you will remember what it is). (Can be deleted later but moving them means they can be put back if there is a problem)
- FTP upload the wp-content and wp-includes folders and their contents from your backup files (into the correct directory eg domain.com/blog). There is no need to replace the wp-admin content folder, in fact better not to, I think
- Check if you need to alter the .htaccess files in the WordPress install directory and the root directory of the hosting (compare what is there to what you had in back up)
- If this is a new host – update the names servers for the domain to direct to the correct hosting location
- Put in the domain into a browser and check if everything is working OK.
Have I missed anything? Have you had any similar experiences?
I’ve previously written about the steps to make a duplicate WordPress site to use as a backup or development area.