What You Need To Know About WordPress Backup and Restore
In this article we, Ghost Host, assume that you are already well aware of how important it is to have a backup of your WordPress site. We're not going to drill that into you in this article. Instead, we will explain the components which make up a WordPress backup, what you should back up, and some tips to follow in case you ever need to restore your site. Knowing this information up-front can help you create a contingency plan you can use to restore your WordPress site, if the need ever arises. Let's do this, folks.
Files
WordPress consists of a number of files which live on a server provided by your WordPress hosting provider. But the situation is more nuanced than that. These files are not part of a single homogeneous group, but are rather a blend of files, each of which can be categorized as being part of one of the following three major groups:
- Core files
- Themes and plugins
- User content
That makes sense, right? Of course there are files which come pre-installed with WordPress, and files which belong to plugins, and how could we forget your customer's uploaded content. Let's dive deeper into these three groups.
Core files
When you first create a WordPress site, you are provided with an initialized installation of WordPress. The provided files come from the WordPress project itself. If you have ever browsed through the directories of your WordPress site you may have seen files such as wp-login.php
, admin.php
, and wp-mail.php
. These are just some of the WordPress core files. Such files are crucial to WordPress because they are the scripts (aka. code) which implement the entirety of what you know as WordPress. Without these files your site would not function.
In the paragraph above there's a little nugget of insight which may someday save your bacon. Did you notice it? Let's walk through it. Imagine that you recently installed an app on your PC or Mac, and then after some time you noticed that the app began to behave erratically? Has that ever happened to you? If not, you haven't been using a PC long enough. Nevertheless, what is the most common step taken to resolve such an issue, aside from rebooting the computer?
Re-install the application.
As silly as it may seem, sometimes the most effective fix is to simply reinstall. This is because the installation process restores the application's core files to their original intended state. Similarly, if you know the version of WordPress you are working with, you can manually restore any core file from the original source.
Here's a fun fact, you can easily view the WordPress core files for any version of WordPress by going to [https://github.com/WordPress/WordPress]
On the left-hand side of the web page there's a drop-down labeled master. Click on that, then click on the Tags tab, and select your WordPress version. You can also use this to check whether a suspicious file belongs to WordPress or not. But beware that just because a file doesn't belong to WordPress doesn't mean it's not legit. In fact, it may belong to a plugin or theme.
Themes and plugins
When you install themes or plugins, the installation process adds files (and database content) to your WordPress site. You can usually find theme files under the wp-content/themes
directory, and plugins under the wp-content/plugins
directory. Similar to WordPress core files, themes and plugins can be restored from their original source, if needed. However, we don't want to get into the weeds regarding these files, other than to bring to your attention the fact that while these files are part of your site, they are not necessarily part of WordPress itself. The same goes for user content files.
User content
When customers perform activities on your site, some of those activities may produce artifacts which are stored as files on your site. For example, if you have user profiles containing a photo users upload, those uploads will likely be stored as files. Usually such files are stored within the wp-content
directory. User content has an important property that is crucial to comprehend: Your site is the source of the content; There's no original source you can use to recover the files.
User generated content is the meat and potatoes of any WordPress site. Whether the user content for your site is not much more than login data (which is stored in the database, BTW), or it makes up 99% of your site files, the fact remains that without user content there would be no need to have a site in the first place. To put it differently, user content is the primary reason why WordPress sites need to be backed up.
But, there's still one more important component of any WordPress site: the database.
Database
While files are visually ubiquitous, databases are not. The most common database-like file is an Excel spreadsheet. So if you'd like, you can think of the WordPress MariaDB/MySQL database as a glorified spreadsheet with many tabs (aka. sheets) and many, many rows. In reality databases are more sophisticated than that, but the structure of a spreadsheet can give you a sense of the structure and purpose of a database, which is to store records of structured data. Let's dig into this a bit more. It's about to get nerdy, so buckle up.
User content consists of structured, semi-structured, and non-structured data. Huh? Let's go through some examples.
- Structured data consists of things which have a stable, well-defined, uh... structure, to them. A good example is user profile data. Such data contains attributes such as name, email, password (hash), sign-up date, etc. You can imagine storing such data into a single row in a spreadsheet, right?
- Semi-structured data is similar to structured data, but the structure is more forgiving. The best example of this is blog posts.
- Lastly, non-structured data is data which little to no structure at all. Examples include images and videos.
Broadly speaking, structured and semi-structured data is stored in the WordPress database, and non-structured data is stored as files. Again, don't take this too strictly. It's just to give you a sense of what is stored where. We say all of this to begin discussing what exactly needs to be backed up.
What needs to be backed up?
We'll be brief here. When considering what you need to back up in order to restore your WordPress site, the best approach is to simply back up everything.
There are three reasons for just not overthinking your backup strategy and instead back everything up:
- Storage is cheap; Take advantage of this.
- Having everything backed up simplifies restoring your site.
- You can spend more of your time doing more important things.
Generally-speaking, computer disks have never been cheaper. Nowadays you can get a significant amount of storage for very little money. Therefore, you may not need to worry about the amount of storage consumed by your backups. If you have everything backed up in a single place, in the event you need to restore your site you can simply go straight to your backups; You wouldn't need to go around hunting for files. In sum, all of this means you can then spend more of your valuable time on the things that matter most to your business.
Speaking of restoring your website, while we sincerely suggest that you back up the entirety of your WordPress site, when it comes to restoring your site, you will be best served by being selective about what you restore.
Restoring a WordPress site
As we said previously, when choosing what to back up we suggest simply backing up everything. But that advice doesn't apply to WordPress restoration. Here's why: __When you restore an entire WordPress site, you're effectively traveling back in time; Everything that had happened since would be erased. Forever.
Unfortunately, there's no clean set of rules and guidelines we can give you to help you definitively decide what you would need to restore to get a broken site working again. What we'll do instead is give you some suggestions, but beware that you will need to think this through very carefully. In short, don't pull the trigger until you have a high degree of confidence in what you're about to restore.
- If you recently made a change to your themes or plugins and that led to a broken site, it may be best to only restore the files.
- If you recently made changes to your site settings and now the site has choked, it may be best to only restore the database.
- If your site has fallen over and is crying in pain, you may have no choice but to restore the files and database.
Again, these are not hard rules. At the end of the day, you need to have a good understanding of your WordPress site in order to decide what needs to be restored in the event of a catastrophe.
What's next?
We hope that reading this article has made you a more informed WordPress site owner. If you get anything from this article, we hope that you understand the importance of having WordPress backups, that they are nuanced and quite powerful, and that with a backup strategy in place you'll be in a good position to quickly get back to business if your site ever goes belly up. But you know what's better than having backups? Having worry-free automated daily backups.
Not having to even think about your backups frees your mind so that you may do what you do best. Click here to learn more.