WordPress database backup – practical examples

WordPress database backup and restore – 4 ways

WordPress database backup and restore will be the main topic of discussion in this article. Generally speaking, the website developers could use a variety of SQL platforms but today we assume that you use Mysql. Practically the same instructions can be applied when using MariaDB.

Before diving into details and provide practical examples I would like to start with a couple of more general questions. What is WordPress database backup and what should we care about it.

WordPress database backups

WordPress database backups

As a database-driven application WordPress requires a database. This is not only the place where all usernames and passwords are stored. The application also keeps its important settings there. The list includes pages, posts, tags, comments, theme and plugins options, and so on.

When certain information is needed WordPress executes a query and retrieves the necessary details from its database.

As to why a reliable backup is needed I would say it may save the day. Not well-protected websites often got hacked which leads to data loss, broken websites, or stolen personal details.

WordPress database backup is usually a single file. It contains all the necessary information to resume the normal functionality of a website. This explains the importance of maintaining up-to-date backups.

In this article, I would like to present 4 different options to take a database backup. It can also be used to restore in case of an emergency situation.

Backup WordPress database using a plugin

Logically when thinking of adding a new feature to an existing website the first thing that comes to mind is installing a plugin. Though there are a number of plugins that support database backup features I personally prefer Updraft.

Wordpress backups with UpDraft

WordPress backups with UpDraft

The plugin has a number of great features such as files and database backup, scheduled events, clone options, search and replace, remote storage, and so on. There are free and paid versions that support different options. The paid one as expected unlocks more features that ease the backup process.

Generating database backups using PhpMyAdmin

This is perhaps the most traditional way to back up a database. It can be used not only with WordPress but also with any other database. As you can see on the following screenshot the graphic interface is simple. All you have to do is select the database from the left column and then click Export. For beginners, it is recommended not to modify the default settings.

WordPress database backup with PhpMyAdmin

WordPress database backup with PhpMyAdmin

Once the download completes you will have your database exported and compressed in SQL file which later can be imported in PhpMyAdmin using the import option.

The other two methods are a little more complicated as they require more knowledge and this way more advanced users might be interested.

Mysqldump to generate WordPress database backup

Once you connect your server over SSH the command you should use is:

mysqldump -u [user] -p [password] wpp_database > backup-name.sql

The required Mysql details are stored in wp-config.php file. You may open it using your favorite editor and look for:

DB_NAME – you will find the database name next to this setting

DB_USER – this is the username

DB_PASSWORD – holds the password

Advanced users familiar with grep command can use:

grep DB wp-config.php

which will print all the necessary details to run mysqldump successfully.

Depending on the specific requirements except for backing up the entire database you could also export certain tables. Here is an example:

mysqldump -u [user] -p [password] wpp_database wpp_comments wpp_users > backup-name.sql

The above example will export wpp_comments and wpp_users tables from wpp_database and store the information in a file named backup-name.sql

WordPress backups using wp-cli

wp-cli stands for WordPress command-line interface and it is used by many to optimize, automate, or speed up maintenance. Basically, its general idea is to give the option to do anything without using the admin panel. For example, you can install and update themes and plugins, execute queries, set crons, generate backups, and many other things.

This tool simplifies the database backup process. The command you need is:

wp db export my-backup.sql

Wp-cli automatically detects all the necessary MySQL details and applies them to the command. Other options I often use:

Database import: wp db import backup.sql

Optimization: wp db optimize

Repair: wp db repair

Database check: wp db check

It is important to note that wp-cli is not pre-installed by default. Detailed instructions on how to download and install it can be found here.

Some other thoughts in the end:

Backing up the WordPress database is important. As indicated this is the place where most of the important information is stored and a damaged or broken database may turn down the entire website.

Working on such problems is quite difficult as retrieving the information might be impossible. Here are a few well-known practices regarding maintaining backups:

  • Always use offsite storage. Those could be remote servers or backup drives that you attach from time to time
  • Try and keep at least 3 backup copies. Sometimes even the backups are broken.
  • Backup your WordPress database regularly. Depending on the volume of the information you add this could vary from once per day to once per week.
  • Encrypt your backups if that is an available option.

In addition, the WordPress database is also a subject of automation. If you are interested, please check the following article on the matter WordPress database management automation

Wordpress database backup - practical examples
Article Name
Wordpress database backup - practical examples
WordPress database backup and restore - 4 ways. Database backup generation using a plugin, PhpMyAdmin, Mysql command, and wp-cli. Practical examples and well-known backup practices
Publisher Name

Do you want to share your opinion?

Your email address will not be published. Required fields are marked *


Рязане и пробиване на бетон Сканиране на бетон Безвзривно разрушаване на бетон
We are not industry specific. We are WordPress specific. We work with everyone to help find solutions for the troubles.
If you show us the problem you are experiencing, we will show you how to fix it. It is that simple.

Easy WordPress automation

Switching from human control to automation is an essential step in increasing the efficiency of website development or maintenance. During the past decade, WordPress advanced a lot and became a fully functional Content Management System. Thanks to some of its internal features a large portion of its functionality could be easily automated. The following articles give ideas on how to apply successful automation:

Speed up WordPress

Speed is an important matter when it comes to website success. In order to appear on the first page except for applying the well-known SEO techniques, you will also have to pay special attention to the performance of your website. We have reviewed a number of options and prepared articles for the most important aspects that include database management and dealing with different types of content:

Extend WordPress features

Extending the standard WordPress functionality by building new features was always a hot topic. Developing themes that provide next-level User Experience could also be described similarly. Thanks to the established standards WordPress developers could create standardized extensions that can be downloaded from the official repository. In the following articles, we described some simple techniques that would help start developing your own extensions:

wppotion - powered by persistence and passion