One of the most heartbreaking experiences I’ve had when advising people about WordPress was with a friend of mine who had spent weeks setting up her site, writing content, and posting images, only to lose everything just as she was about to launch because she mistyped a command on her VPS’s command line.
Of course, it’s sad to lose all that work, but what made it worse is that she had thought she was doing everything right — she had a backup plan, and every couple of days would use FTP to copy the contents of her site from the server onto her home machine.
Unfortunately, what she copied was just the WordPress installation along with her themes and plugins. She didn’t copy was the database, which is where most of the content lives. Her backup was great if she wanted to resurrect a theme, but no use at all for recreating her posts and pages. It’s an expensive mistake to make, and I’ve seen it happen more than once.
The first thing to understand about WordPress is that there are two main components: the WordPress installation folder and the database. The WordPress folder on the server contains the core of WordPress — mainly PHP files — and components of plugins and themes. None of the site’s content lives in that folder. It is stored in a MySQL database that is accessed by PHP code to build the web pages that are sent to browsers. To restore a site, it is useful to have both. However, because everything in the WordPress folder (with the exception of modifications to themes) can simply be reinstalled, it’s the database, with its unique content, that should be safeguarded at all costs.
Doing so is relatively easy. If you’re at all familiar with MySQL, dumping the database from the command line should be a cinch, so I’m not going to discuss that here except to point you in the direction of the WordPress Codex page on the topic. If you aren’t familiar with MySQL, your best option is probably to use a plugin that offers database backup functionality.
There are several to choose from, and my first choice has usually been WP-DB-Backup, although because that plugin hasn’t received an update for over a year and isn’t compatible with the most recent version of WordPress, I’m going to suggest you take a look at WP Database Backup. It has an intuitive interface, which makes it easy to download the database (which looks like a big text file) and just as easy to restore it should you need to. Once the database is downloaded, you should keep it somewhere safe. And remember, every change you make to your site’s content will change the database, so you should back up frequently.
Although, backing up the database on its own is possible and in some circumstances desirable, I usually advise WordPress users to take advantage of a comprehensive backup solution. VaultPress, a tool from the company behind WordPress, is probably the best premium solution, offering a cloud-based backup platform that takes care of regular backups of the site and its database.
Whichever option you choose, it’s important that you make regular and comprehensive backups. It may seem unlikely that something bad will happen to your site, and it probably never will, but the loss of a site and all its content can be catastrophic, so the effort of backing up is a worthwhile hedge against disaster.