Sébastien Laframboise

Back up WordPress files and database separately

Back up WordPress files and database separately

A complete WordPress backup isn’t just copying a folder or exporting a database. To be able to restore your site, you must preserve two complementary sets: the files and the database.

This distinction is essential. The files include media, the theme, plugins and configuration. The database stores content, settings and many internal relationships of the site. A WordPress files-and-database backup must therefore combine these two parts into one coherent set.

Why WordPress relies on two distinct sets

WordPress runs PHP files on your server, then reads and writes data in a MySQL or MariaDB database. Official documentation confirms that WordPress files and the database are usually located in separate places. So copying the site directory generally does not copy the database. WordPress documentation on file backups clearly explains this separation.

Imagine your site as a library. The files represent the building, the shelves and the illustrated books. The database represents the catalogue that shows each book’s title, author, category and location. If one of the two is missing, you won’t get the library back as it was.

The same logic applies to a shop, a brochure site or a blog. The more content, accounts or settings your site has, the more indispensable the database becomes.

What the files side contains

The files include everything that lives in the WordPress directory. Some items can be replaced by an official WordPress copy. However, many files directly reflect your site and must not be forgotten.

The wp-content folder

The folder wp-content deserves special attention. It normally contains themes, plugins and files uploaded to the media library. Your images, PDF documents, videos or other media are often found in wp-content/uploads.

As a result, a database export will not bring back your product photos, illustrations or downloadable files. It may preserve references to them, but not the files themselves. Before cleaning up, also check how to clean the WordPress media library without deleting files that are in use.

The wp-config.php file and configuration files

The file wp-config.php connects WordPress to its database. It includes, among other things, the database name, the user account, the host and the table prefix. It can also contain settings specific to your installation.

The official reference on wp-config.php states that this file is located at the root of the installation and contains the site’s basic parameters, including database connection details. It is therefore one of the important files to preserve.

Depending on your hosting and customizations, other files may also matter. For example, a file .htaccess, custom scripts or directories placed outside of wp-content can influence the site’s operation.

What the WordPress database contains

The database keeps the information WordPress needs to retrieve, modify and display. It’s not just for posts. It also contains the settings that give the site its current behaviour.

WordPress tables include posts, metadata, comments, categories, tags, user accounts and options. The wpdb class reference describes these tables, including those for posts, users, comments and options.

Content and its structure

Your posts, pages, products and custom content are typically stored in the database. Titles, text, dates, publication statuses and category relationships are also stored there.

The media library clearly illustrates the connection between the two sets. The image file is located in the server files. However, WordPress stores in the database the information that identifies it and associates it with content. If you restore only the images, your media library may lose its context. If you restore only the database, pages may point to missing files.

Settings, users and plugin data

General settings, several theme parameters and many plugin configurations are stored in the database. The WordPress options API specifies that these values are kept in the options table.

Additionally, some plugins create their own tables. A backup limited to only the standard WordPress tables can then omit useful data, such as forms, bookings, specialized settings or transactional data. Check that the export covers all tables used by your installation, including those added by plugins.

What an incomplete copy cannot restore

Available copyWhat may be missing
Files onlyPosts, pages, settings, accounts, comments and plugin data stored in the database.
Database onlyImages, documents, theme, plugins, custom files and the wp-config.php file.
Database or files from different datesLinks to missing media, inconsistent content, settings that no longer match the files.

An exported database often produces a file of the type .sql, sometimes compressed. This file becomes part of the backup itself, but it must be imported into MySQL or MariaDB to restore the data. WordPress documentation on backing up the database notes that a database export covers posts, pages, comments and settings, without including themes, plugins, uploads or the file wp-config.php.

Avoiding a mismatch between files and data

A backup is more useful when its files and database represent roughly the same point in time. Otherwise, the database may contain a page that references an image uploaded after the files were copied. Conversely, the folder uploads may contain media that the database does not yet know about.

You don’t need to know every table to apply this principle. Instead, remember that a full backup should pair a copy of the files with an export of all database tables, using a common date or identifier.

This check becomes especially important before a sensitive change. For example, checking the PHP version before changing it is one of those actions where a complete rollback point better protects your site.

A simple checklist to verify the scope of your backup

Without choosing a specific tool or addressing frequency, you can review what your solution actually produces. Look for the following:

  • a copy of the WordPress directory, including necessary subfolders;
  • the folder wp-content, with its themes, plugins and uploads;
  • the file wp-config.php and the relevant configuration files;
  • a readable export of the database;
  • all tables, including those created by plugins;
  • files and a database from the same backup set.

Don’t assume that a compressed folder automatically contains the whole site. Open it and check its structure. Likewise, don’t assume a partial table export is sufficient just because your site seems simple today.

Finally, distinguish «having a copy» from «being able to restore a site.» When you want to confirm the latter, follow a controlled method to test restoring a WordPress backup before an emergency.

Keep the right mental model

The files give WordPress its assets and code. The database gives it content, settings and relationships. One without the other does not faithfully reconstruct your site.

Before considering a backup complete, ask a simple question: «Does this copy contain both what WordPress displays and what it needs to know to display it?» If the answer is yes, you’re starting from a much stronger position.