How To Backup Your WordPress Database
Made changes to your site that you regret? Updated a plugin that crashed your site? Have you been hacked and lost precious content? There is one solution for all of them: restoring a full site backup.
Why a full site backup, you may ask? Well, there are two components that make up a WordPress site: files and a database. They’re both equally important for a site to function. But, you’ll find a lot of articles recommending you to take a WordPress database backup, suggesting that a database backup is sufficient to restore your site from a crash. That is not even close to accurate. Partial backups are useless and can’t fully restore your site. We recommend that you always take complete backups of your whole site.
With that in mind, this article is a guide on helping you backup WordPress database: one of two parts of a full site backup.
TL;DR: There are so many things that can go wrong when managing a WordPress site that taking regular backups is the only way to go. Use BlogVault, the backup plugin that takes a backup automatically, as per a schedule that you customize, and with no effort from your end.
What does it mean to backup WordPress database? Your database backup contains posts, pages, widgets, plugin settings, theme settings, and other user-generated content. This is all crucial information for your site to function. In this article, we’ll talk about the various ways to backup WP database. So, keep reading.
How to backup WordPress database using a plugin
This is the absolute easiest way to take a WordPress database backup. We recommend using a backup plugin like BlogVault because it’s less risky than a manual backup and easy to perform.
Once you have a BlogVault backup, you can extract the database file and save it elsewhere, if you so choose.
- Install and activate the plugin: First, hover over Plugins on the sidebar, and click Add New. Look for BlogVault in your plugin directory, and click Install and Activate. Scroll down till you see BlogVault and click Settings.
- Create an account: Fill in your email address and click Submit. On the next page, click Continue and Back to Dashboard. This will take you to your BlogVault account dashboard. Creating an account also automatically backs up your whole site for the first time. Give it a few minutes.
If you’d like to store a backup of your WordPress database to your computer, for migration purposes perhaps, follow these steps:
- Initiate download of the backup: Once a backup is done, click Details in the Backup section of your site dashboard. Then click the download button.
- Select files to download: BlogVault automatically selects the entire site to export, so just click Continue. This may take a few minutes and you’ll be able to see the progress.
- Download link: Once done, click Download Link on the right and all your files will be exported as a zip folder. This folder will have a lot of different types of files but the database file is the .sql file. The rest are your site files.
How to backup WordPress database manually (4 Ways)
Backup database using cPanel Backup Wizard
Most hosts have a cPanel and a Backup Wizard feature that makes a WordPress database backup very easy. Here’s what you need to do:
- Go to the Files section of your cPanel and click Backup Wizard.
- Click cPanel Backups in the Other cPanel Backups section.
- In the Partial Backup Section, find Download a MySQL database and click the name of the database.
Note: To find out which database to export, look for the database name in the wp-config.php file.
- Give it a minute and it should download as a .sql.gz file.
If you do have a cPanel but not the Backup Wizard, use the phpMyAdmin method as seen in the next section.
Backup WordPress database using phpMyAdmin
If your web host doesn’t provide phpMyAdmin, they may use another database management tool like Adminer. Either way, the steps are mostly similar. You need to export the entire database into an SQL file. In our tutorial, we’re demonstrating how to take WordPress database backup using phpMyAdmin via cPanel.
- Access your phpMyAdmin: Go to the cPanel with your site’s web host and look for phpMyAdmin in the database section.
- Locate the right database: Click the Database tab. Select the database you need to export.
Note: To find out which database to export, look for the database name in the wp-config.php file.
- Export the files: Select all the files and click Export.
These two methods are the easiest. The SSH method in the next section is long and time-consuming.
Backup WordPress database using SSH
As with using SSH to backup your site files, you can use SSH to export the database to an SQL folder as well. You will need to have WP-CLI installed to do this.
- Connect to your site server using SSH. In most cases, the credentials will be the same as your FTP ones.
- Navigate to the wp-config.php file: This is most likely in your site’s root directory. Execute the following command:
wp db export filename.sql
Replace the filename with an appropriate name for your database export.
- Download the file to your local machine: Exit the server and download the database file using the following command:
scp username@serveraddress:rootfolder/filename.sql localfolder
This will save your file to your local machine.
Backing up the database using MySQL commands
phpMyAdmin can’t handle backing up large databases. For such situations, you can use MySQL commands. It’s an efficient, secure but complex way of using mysqldump utility. It requires adding custom code to the command line. If not, here are the steps to exporting your database:
- Connect to Server: Here is the code to login to your server with ssh
ssh useername @ouripaddress
Replace username and ouripaddress with your username and actual IP address. Then add the password when prompted.
- Exporting the database:
First, navigate to the correct directory using the following command.
Replace the text after cd with the actual path.
Then, export the database with the mysqldump utility. The command is as follows:
$ mysqldump -u USER_NAME -p DB_NAME >file_name.format
Replace username with the correct username, database name, file name and the format you’d like it to export as.
You’re now done. Congratulations on exporting your database successfully.
Why should you backup your WordPress Database
Once again, we don’t recommend that you only backup your database. A full site backup is always the way to go. Now, let’s talk about why you’d want to backup your database (and files) in the first place:
- Restoring a crashed site: Plugins and themes updates are notorious for potentially crashing your site. You always need a backup that you can restore in case your update is incompatible. WE recommend having a backup before and after any changes you make to the site. We also have an article on how to restore a WordPress site if you’d like to learn more.
- Reversing a Wrong: Maybe you’ve realised that the new site design is bringing in less conversions than the previous one. Maybe, you’ve accidentally deleted a whole page. Whatever your wrong, a backup restore can make it right.
- Malware infections: Some malware hacks can deface pages on your site. Security plugins like MalCare can definitely clean your site and get rid of the malware. But it cannot restore your site to it’s previous glory. That’s where backup restores come in.
- Migration: If you’ve managed a site before, you know that there are many reasons why you’d need to migrate to a different host or server. May your server can’t handle the increased traffic that you have. Maybe, you’ve noticed that a different host has better features or support. Either way, to migrate a site, you need to export your entire site and import it to your new host or server. We have an article that walks you through the whole migration process.
Whatever your reason for a backup, we recommend using BlogVault. You can automate, schedule and have real time backups for your site so you always have the newest version to restore. The restore process only requires a few clicks. With BlogVault, backing up a site has never been easier, safer and more assured.
Recommended read: how to backup and restore your WooCommerce site.
What can go wrong when taking a backup of your database
- Incomplete site recovery: If you’ve only taken a WP database backup, you’ll be unable to restore your full site because a site restore requires both files and a database. A partial database backup is completely useless when you really need it and it is why we recommend you backup your full site.
- Failed backups: Something as simple as losing connectivity to your server can cause a partial or failed backup. This is especially probable when you’re using a manual backup method for your database. The worst part? You may never know it was a failed backup unless you test the restore. To do so, restore your backup on a staging site. Here’s an article talking about how to do so.
- Server load: Backing up your site database is a resource-intensive process on your server. Timeouts and downtimes are common. This is why we recommend either you backup WordPress database when traffic is low to your site or use a backup plugin like BlogVault that takes incremental backups.
- Time-consuming: This is especially true for larger sites. It takes a long time for your entire database to be backed up and downloaded to your computer.
- Storage: A database backup can be a few GBs and that can take up valuable real estate on your local computer’s storage. With BlogVault, your backups are stored on Amazon S3 servers. So there is no impact on your computer.
While there are so many reasons to backup a database, it is essential to take a full backup of your full site. The best way to go about doing so it to take a backup with BlogVault. With BlogVault, backups are automatic, can have a custom schedule and taken in real time. In other words, with BlogVault, you never have to worry about backups again.
How to backup WordPress database?
The most efficient way to take WordPress database backup is to use BlogVault, a trusted and easy-to-use backup plugin. Install the plugin and sign up. It will automatically take a full backup but you can download just the database if you want. Here are the steps to do so.
How to take a full backup of your site?
Use a WordPress backup plugin like BlogVault to back up your full site. Just install the plugin and sign up. It will automatically take a full backup.
How often should you take a backup?
We recommend taking a backup daily, and before updating anything on your site: WordPress versions, plugins, themes, etc. If you’re a WooCommerce site, take real-time backups. BlogVault takes real-time ones and automatically takes a backup before you update a plugin or theme (if you’re using the BlogVault dashboard to update them).
How can you schedule backups?
You can schedule backups using BlogVault. Once you install the plugin, you should be able to access the site dashboard on BlogVault. On the left, you see a site overview. Select the hamburger icon below the site name. Next, click Sync Time and select what time of the day you’d like to schedule to sync your site.
Shreya has been a writer for as long as she can remember. Now, she writes articles that help WordPress users manage the sites that they're proud of, with little to no coding