It is terribly alarming to find out that recipes, posts, or comments on your blog are unexpectedly missing. Most often this is because some of the data in your Wordpress database is corrupt. This can happen after your Wordpress database (or server) crashes or is stopped abnormally. Unfortunately, this is a rather common problem and if you search on the Internet you will find a number of people who have had troubles with corrupt database tables. Despite this, there are ways to avoid and repair data loss on your blog. In this article, we gather together some of the best practices and recommendations to help prevent data loss as well as mitigate it should it occur.
Your database holds all of the important data for your blog such as your posts, your reader's comments, and your recipes. As such, it is very important that it is healthy and responsive. Normally, everything just works and you are blissfully unaware that the database is even there; however, sometimes the database is stopped abnormally due to a server crash, a power outage, or perhaps an improper server reboot or some other reason. When this happens, many Wordpress databases may become corrupt. The reason is that the database may be in the middle of changing data and then it is suddenly halted. It is kind of like as if you were writing a very important letter to a friend and then you were interrupted only to come back and not remember exactly where you left off or what you originally had in mind.
What can you do to overcome this? There are a number of options available to you. Most of these are rather technical and so I encourage you to find a competent qualified person to assist you. Often it is best to hire a professional to help you get set up and address subsequent issues.
Here are four ways to address database corruption (listed best to worst):
- Change your default table type to InnoDB
- Backup your database
- Repair corrupt database tables
- Contact support at yumprint to get "lost" recipes
1. Change your default table type to InnoDB
Many Wordpress installations use MySQL to run their database. Older versions of MySQL (those prior to versions 5.5) use MyISAM tables as the default table engine type. While MySQL originally gained fame for its superb performance in large part due to MyISAM tables, they lack the ACID properties that many have come to expect from modern databases. This means that if data is being written to a MyISAM table when the database is suddenly stopped that the table with the database may become corrupt.
Fortunately, MySQL provides another table engine type, InnoDB, which supports ACID properties and will not become corrupt under abnormal failure. If you have MySQL 5.5 or later then this is done by default. Otherwise, you can change the default table engine type to InnoDB to prevent data corruption in your database.
For those that run on PostgreSQL, tables are "safe" by default. If you run some other database check with a qualified database administrator to see if your database is "safe" under crash conditions.
It should be noted that InnoDB is not as performant as MyISAM, but if you have corrupt tables performance doesn't matter much does it?
To change your default storage engine to InnoDB read here (note the typo). Or to change an existing table's storage engine see these instructions.
2. Backup your database
Every blog should back up its data frequently. Imagine your utter devastation if you lost everything on your blog: your posts, your comments, your recipes, and your readers. Prevent this catastrophic scenario by regularly backing up your data.
Some hosts and Wordpress installations do this by default and if this is the case with you then great! Just make sure you or someone you trust knows how to restore these backups.
For many people, their blogs are not backed up at all. In fact, it is quite alarming how many are not protected.
Backing up your blog makes a copy of all of your data on a regular basis usually daily or weekly depending on how active your site is. Then if data is lost or damaged you can restore the original data. This protects your blog from catastrophic damage. It's like data insurance and is industry best practice.
It should be noted that although everyone should seriously consider backing up their blog, backups aren't entirely perfect since new data that occurs between the point of the last backup and the data loss event is not backed up. Usually though, if you backup frequently this isn't a major issue. And certainly, losing a small amount of data is better than losing everything.
Here are a couple of links to get your started on how to backup your Wordpress site.
Wordpress advice on backups
What's the best way to back up your Wordpress site?
3. Repair corrupt database tables
If you cannot change your table's engine to InnoDB or use PostgreSQL then you can expect that at some point during an unexpected failure that a table will become corrupt. Often this is only a slight inconvenience. The problem will often manifest itself as missing data on your blog. It can be frightening, but don't be alarmed it is caused because Wordpress cannot access the data in the corrupt table. So if your posts, your comments, or your recipes go missing then check the database or server logs to see if the problem is a corrupt table.
Remember that the corrupt table is a symptom of the root cause which was likely an unexpected server failure that interrupted a data write to the now corrupt table. Thus you might want to investigate to see if the server failure has a systemic cause so that you can solve the real problem.
To repair the corrupt table, you can use the MySQL console and use the following command:
repair table TABLE_NAME;
If you don't feel comfortable with the MySQL console or don't have access to it provided by your host then you can use phpMyAdmin. Just select the tables you want to repair and choose to repair them.
If you find yourself doing this frequently, then you can change your Wordpress settings to automatically repair corrupt tables. Just change your wp-config.php file and add the following code:
4. Contact support at Yumprint to get "lost" recipes
If all else fails when you can't access your recipes that you wrote with the Recipe Card plugin, you can contact email@example.com and request a copy of your recipes. Make sure you tell us your blog url and we will send you a text copy of the principal parts of your recipe. Although this preserves the core aspects of your recipe, you will still need to copy and paste them into your posts again as well as select pictures and so on.
You want to continue to enjoy your blog and the community that you are building. It is vital that you protect the data that enables the conversation to happen. The best practice is to prevent data loss by configuring a database to not have corrupt tables or to regularly backup your data in order to restore it to its previous state; however, in the event of data loss you can often recover data through repairing tables or as a last resort requesting "lost" recipes from support at Yumprint. Please protect your data.