Home Blog WordPress Management How to back up your WordPress database in 4 easy ways

How to backup WordPress database in 4 easy ways

How to back up your WordPress database in 4 easy ways

The database is the heart of your WordPress website. All of your content – including posts, pages, comments, tags, and categories – is stored there, and losing it can spell disaster for your website.

That’s why conducting a frequent WordPress database backup is one of the best things you can do to protect your website. Should your data ever become corrupt or compromised, you can always restore it.

This tutorial will teach you how to back up your database with and without a plugin, plus tips and best practices.

Why backups are essential

Data loss is an unfortunately common occurrence. Sometimes data loss happens because of accidental deletion or glitches within WordPress, while other times it can be malicious and intentional.

Either way, a backup makes it possible to restore your database to a previous version, minimizing data loss. Here’s why backing up your site is so important, and common reasons you’ll need a backup.

  • Data loss prevention: Major data loss can be devastating, and can single-handedly shut down your website or business. You can lose months or years of content in an instant if you don’t have a backup.
  • Recovery from cyberattacks: Bad actors may deface or even delete your database. A backup doesn’t prevent this from happening but it does help you restore your database to a state before it was defaced, corrupted, or deleted.
  • Glitches and corruption: Sometimes WordPress, or a plugin or theme you’ve installed, can be buggy. Those glitches can unfortunately lead to a partially or totally corrupted database.
  • Disaster recovery: Even if you keep all bad actors out and are lucky enough to avoid any serious glitches or make any mistakes, some things are out of your hands. Your server may crash, or your hosting provider may be struck by a disaster that leaves your data inaccessible. Having a local backup can save your content from permanent deletion.

How to backup your WordPress database using a plugin

Using a plugin is the easiest, quickest, and most user-friendly way to perform a WordPress database backup. This is suitable for beginners or anyone who doesn’t want or need to do a manual backup.

For this tutorial, we’ll be using UpdraftPlus, as it’s the most popular WordPress backup plugin.

Navigate to Plugins > Add New Plugins. Type updraftplus into the search bar, then Install and Activate the plugin.

Head to Settings > UpdraftPlus Backups and click the large Backup Now button to download a backup of your website.

You’ll see a new pop-up. If you just want your database (no backup WordPress files, plugins, etc), untick Include your files in the backup and keep Include your database in the backup checked. Then click Backup Now.

Optionally, you can go to the Settings tab and set up scheduled backups to be sent to various places like your email, Google Drive, UpdraftVault, etc.

With that, your data is safe and ready to be restored should you ever need it. If UpdraftPlus doesn’t work for you, there are plenty of other backup plugins, like Duplicator or WPvivid that will do the trick.

How to manually perform a WordPress database backup

Sometimes a backup plugin isn’t ideal. Maybe you want to avoid installing plugins where possible, and would rather do the job yourself. Or maybe no plugin has the exact features you’re looking for.

Whatever the case, there are plenty of ways you can manually do a WordPress database backup. Below are some of the most common:

Using cPanel

Many web hosts offer their own backup tools. These are functionally similar to WordPress backup plugins but you access them through your host’s custom dashboard. If your host uses cPanel, then there’s a backup feature built in.

Through cPanel, you can download a copy of your site and/or database on command, schedule periodic backups, or a combination of both.

Here are some general instructions to help you download a database backup from cPanel:

Log in to your web host’s cPanel dashboard. You can usually find a link in your hosting provider’s dashboard.

If you have multiple WordPress websites, open the one you want to back up.

Click Backups to begin setting up your database backup.

From here, you can either click Download a Full Account Backup to download your site files as well or scroll down to the Download a MySQL Database Backup section to only back up the database. Click on your databases to download them directly.

Although most well-known WordPress hosting providers use cPanel, some might not. If your web host uses a custom dashboard, check with them to see if they provide their own backup tools.

phpMyAdmin

If you need to manually backup your database, you can do so through phpMyAdmin, a database manager used by most hosting providers.

Optional: Check your website’s wp-config.php file (see below) for DB_Name, which is the name of your website’s database, plus DB_USER and DB_PASSWORD, which are your login credentials.

// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'name' );

/** Database username */
define( 'DB_USER', 'user' );

/** Database password */
define( 'DB_PASSWORD', 'password' );

/** Database hostname */
define( 'DB_HOST', 'host' );

Log in to your website host’s dashboard and look for phpMyAdmin or Database. If you don’t have your login credentials or can’t find the database manager, contact your host for help.

On the left, you’ll see a list of databases. Find your website’s database – if you checked wp-config.php, look for the one identical to the DB_Name value and click on it.

Click the Export tab at the top of the page. Make sure it’s in SQL format and click Export to download a MySQL database backup.

SSH method

SSH, or Secure Shell Access, allows you to remotely access your website and database from the command line. Unlike other programs, this doesn’t involve a visible interface. You just type commands in and execute them.

Here’s how to back up your database from the command line.

Log in to your website host’s dashboard and look for an SSH option. You may need to manually create your SSH credentials, and some hosts provide a dashboard to input commands. Can’t figure out what your SSH credentials are? Contact your host for help.

If your host does not provide an SSH interface, you can either open the Terminal (Mac and Linux) or install an SSH client like PuTTY (Windows).

When using the Terminal, paste in the ssh command provided by your web host. If you’re using PuTTY, fill out Host Name and Port and make sure SSH is selected. Then click Open. A terminal window will launch.

Enter your SSH username and password when prompted.

Once you’re in, enter this command, replacing dbuser and dbname with the proper credentials:

mysqldump -u dbuser -p dbname > example.sql

With that, you should be done.

Common issues and how to solve them

As simple as these methods are, backing up a website can be quite complicated in the back end, and things may not always go smoothly.

If you run into issues or errors, check here for the solution – and to learn about some common mishaps before they strike you.

Incomplete backup or missing files

To completely back up your website, it’s important to back up not just the database but also the website files.

Your website files (accessed through FTP) store the design and functions of your website. The database stores written content like posts and comments.

One common mistake is copying your website’s files through FTP, expecting it to save your posts, and only realizing once it’s too late that those are stored in the database. Backup both to avoid this mishap.

Lost, damaged, or corrupted backups

Sometimes backups can be corrupted as they’re being compiled, or not all of the data gets transferred over. Or maybe you lost your backup and can’t find it at all!

This may be due to the particular backup plugin you’re using, so if you’re having this issue crop up frequently, you may wish to try out a different plugin instead.

If all your backup plugins seem to result in corrupted data, there might be a problem with your site itself, and it’s best to get a developer to check that out.

Otherwise, the solution here is simple: store multiple backups in multiple different places. If you ever lose track of a backup or end up with a corrupted one, all isn’t lost.

Slow backup

If you try to back up your database and it takes forever, there are several potential problems.

Look out for these potential issues:

  • Slow Disk I/O and CPU: If your website’s server itself is very slow, then uploading all your website and database files will simply take a while. The only thing to do is contact your host or upgrade your plan.
  • Large files: If you have very large files or massive databases included in the backup, they may be seriously slowing down backups. You may wish to exclude these files from automatic backups and make sure you don’t have a plugin creating huge databases.
  • Cron job issues: If your automated backups seem slow or broken, the issue could be with WordPress’ cron jobs. Check your logs and make sure cron jobs are working properly, and large files aren’t clogging it up.
  • Old zip module: UpdraftPlus falls back to PclZip, which is very slow if PHPZip or Binary Zip are not available. You can check cPanel or contact your web host to make sure PHPZip is working.
  • Outdated PHP version: If you’re not using PHP 8 or above, it’s a good idea to upgrade. Besides being a security concern, PHP 5 is much slower.
  • Slow data transfer: Once your backup files are compiled by a plugin like UpdraftPlus, they’ll need to be sent somewhere else, either to your computer’s hard drive or a destination server. If there’s a data transfer cap on the server or your PC is slow, transferring the files could take longer than normal. Try sending the backup to a different server.

Low PHP Memory Limit

Performing a WordPress database backup can take a lot of memory, but some web hosts set the limit very low. If your backup plugin runs out of memory, you’ll need to increase the PHP memory limit.

It’s best to contact your web host to do this for you if you don’t know what you’re doing, but you can also do it manually.

Access your website files via an FTP client like FileZilla.

Find wp-config.php in the root folder of your website and open the file.
Search for WP_MEMORY_LIMIT. You should see a function like:

define('WP_MEMORY_LIMIT', '32M');

Change the number (32M in this example) to 32M, 64M, 128M, or 256M – you don’t usually need more than 32M or 64M.

define('WP_MEMORY_LIMIT', '64M');

Now, find and open php.ini in the root directory or the wp-admin directory. (If you’re on shared hosting, you won’t be able to edit this file.)

Search for memory_limit and change this value to the one you set above.

Now, find and open .htaccess in the root directory. You may need to enable hidden files and directories in your FTP program.

Search for php_value memory_limit. Change the value to the one you set above.

If this doesn’t clear up the memory issue, your web host likely has locked the memory limit too low. You’ll need to contact them if this is the case.

Insufficient Server Resources

Backing up a website can be a server-intensive task, and shared hosting isn’t always up to the task. This can occur especially often if you have a very large website and a server that can’t quite keep up.

Many backup errors you’ll see are caused by your server not having enough resources to handle them. You’ll need to upgrade your web host, or perform a manual WordPress database backup if you just can’t seem to get any plugin to perform a WordPress database backup.

Backup best practices

When you’re creating a backup plan for your website, there are some best practices worth keeping in mind. 

Straying from these essential strategies could lead to your database backups failing you when you need them most.

Backup on a schedule

One backup isn’t enough – it’s extremely important to regularly create new ones as your website updates. While an old backup is better than no backup, you wouldn’t want to lose that perfect article you just published yesterday.

Backup frequency will depend on how often you update your website, and how important those updates are.

  • Monthly WordPress database backups are suitable for websites that rarely update, a few times a month at most.
  • Weekly or fortnightly backups are best for sites that publish and update semi-frequently.
  • Daily backups are necessary for high-traffic websites that update every day or close to it.
  • Hourly backups are only needed for enterprises with constantly updating websites.

Nobody is perfect, and if you’re trying to keep up with daily or weekly manual backups, you’ll inevitably slip up. It’s best to enable automated backups rather than trying to remember to do it yourself.

Store multiple backups in multiple locations

When it comes to backups, follow the 3-2-1 rule: store three copies of your data on two different media, with at least one of those being off-site.

For example, you may want to store a backup on your own computer, on remote/cloud storage like Dropbox or Google Drive (or on a physical removable storage device), and on your web host’s server.

Encrypt and secure backups

It’s important to protect your database when you back it up, as it can contain sensitive information like user credentials and customer payment information.

Databases and other backups should be encrypted both when at rest (where you’re storing them) and in transit (when moving to that storage). For example, don’t use FTP to transfer your database – use SFTP instead.

You can also protect your WordPress site and its data by keeping an eye on things with an activity log plugin and using Melapress’ login security plugin to lock bad actors out.

Test backups

Though rare, it’s possible to download a backup that’s corrupted or malformed in some way. When you try to restore it, it just won’t work. And if you don’t have any other backups saved, you’re out of luck.

This can be avoided by proactively testing your backups before you need them. You can create a temporary website, like a staging or cloned site, and attempt to restore the backup.

If it doesn’t work, you know it’s time to try a new method – maybe your plugin doesn’t work, or your manual backup went wrong. Troubleshoot the error or try something new.

Protect your data with backups

Today we discussed how to backup WordPress databases, both with and without a plugin. Plus tips on troubleshooting any backup issues you may run into, and best practices when saving and storing backups.

With this knowledge, you’ll be able to restore your database if anything goes wrong – glitches, corruption, accidental deletion, or intentional defacement. Anything can happen, and it’s important to be proactive and back up your database before it does.
As a final step, you should also consider downloading a WordPress security plugin. This can protect your database and website content from unwanted changes.

Posted inWordPress Management
Brenda Barron
Brenda Barron

Brenda is a freelance writer with over a decade of experience with web design, development, and WordPress. When not click-clacking at the keyboard, she’s spending time with her family, playing music, or taking up a new hobby.


Leave a Reply

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

Stay in the loop

Subscribe to the Melapress newsletter and receive curated WordPress management and security tips and content.

Newsletter icon

It’s free and you can unsubscribe whenever you want. Check our blog for a taste.

Envelope icon

Take the Melapress Security Survey 2024

Share your perspective
and WIN