How to Back Up a WordPress Site and Test a Restore
A WordPress backup is useful only when it contains the parts needed to rebuild the site and you know how to restore them. Downloading the database alone does not save your themes, plugins or media, while copying the website files alone does not save posts, pages, comments and settings.
This guide explains a practical backup routine for a typical single-site WordPress installation. You will learn how to create a complete backup using your hosting file manager or SFTP, export the database with phpMyAdmin or WP-CLI, store the backup safely, and test a restore on a separate staging or local site. The aim is to make recovery predictable—not to change or migrate your live website.
What a complete WordPress backup must contain
A typical WordPress site has two separate components that must be backed up together:
- The database: Posts, pages, comments, users, settings, menus, and data stored by plugins and themes. A database export is commonly saved as an SQL file, sometimes compressed as
.sql.gzor another supported archive. - The website files: WordPress core files, themes, plugins, uploaded images and documents, custom code, configuration files, and server rules such as
.htaccesswhen used.
Pay particular attention to wp-content, which normally contains uploads, themes, plugins and other site-specific content, and to wp-config.php, which contains database connection details. Keep configuration files private because they can contain credentials.
WordPress’s official backup handbook explains that the database and files are separate and that both are needed for a full restore. See the WordPress backup guide for the underlying details.
Choose a backup method
You can use one method or combine them, depending on the tools your hosting provider makes available.
- Hosting backup or snapshot: Convenient when the host can restore both files and the database. Confirm what is included, how long backups are retained, and whether you can download a copy.
- Manual backup: Download the site files through SFTP or the hosting file manager, then export the database through phpMyAdmin. This gives you files you can store independently.
- WP-CLI: Useful for administrators who have shell access. It can export and import the database, but it does not replace the separate file backup.
Do not assume that a host’s “backup” covers everything. Check that the database, uploads, themes, plugins and configuration files are included. Keep an independent copy outside the hosting account where practical.
Before you start: identify the correct site and database
- Write down the website address and the hosting account or server where its files are stored.
- Locate the WordPress installation directory—the document root or the folder containing
wp-admin,wp-includesandwp-content. - Check
wp-config.phpfor the database name and the$table_prefix. Do not copy database passwords into notes, screenshots or public messages. - Check whether the database is shared with another application. If it is, identify the WordPress tables before exporting selected tables.
- Choose a quiet period if the site receives orders, registrations, comments or form submissions. For a busy site, coordinate the file and database capture so the two parts represent a reasonably consistent point in time.
- Create a private backup destination with enough free space. It should not be a publicly accessible folder inside the website’s document root.
Step 1: Export the WordPress database with phpMyAdmin
phpMyAdmin is a common browser-based database tool provided by hosting control panels. The exact route to it depends on your host, but the export process is similar.
- Open phpMyAdmin from your hosting dashboard.
- Select the database whose name matches
DB_NAMEinwp-config.php. Check the database name carefully before continuing. - Open the Export tab.
- For a straightforward full database export, use the quick export option if it includes all required tables. If the database is shared or you need more control, use the custom option and select the tables belonging to this WordPress installation.
- Choose SQL as the format. Use gzip or another supported compression option if the database is large and your hosting tool offers it.
- Start the export and save the downloaded file in your private backup folder. Give it a descriptive name that includes the site and date, for example
site-database-2026-11-24.sql.gz.
If the database contains more than one application, do not blindly export only tables beginning with wp_. The table prefix can be different, and plugins may create additional tables. Use the value in wp-config.php and check the database structure before selecting tables.
The phpMyAdmin import and export documentation explains the available export and import options. Hosting interfaces may use different labels or restrict file sizes.
Alternative: export the database with WP-CLI
If WP-CLI is installed and you have shell access, run the export from the WordPress installation. Create a private directory first and use a path that is outside the public document root and writable by the account running WP-CLI:
mkdir -p /home/your-user/private-backups
wp db export /home/your-user/private-backups/site-database.sql
Replace the example directory with a real private path on your server. Check that the export file exists and has a plausible size before moving it off the server. The command uses the database connection values loaded from wp-config.php. See the official WP-CLI wp db export reference.
Step 2: Back up the WordPress files
Use SFTP or your hosting file manager to download the WordPress installation. For a straightforward full backup, copy the complete installation directory, including hidden files where your server uses them.
If you need to check the most important areas, confirm that the copy includes:
wp-content/uploads— images, documents and other media.wp-content/themes— installed themes and any custom theme files.wp-content/plugins— installed plugin files.wp-content/mu-plugins— must-use plugins, if the directory exists.wp-config.php— database and site configuration; keep this file private..htaccessand other custom root files, if present.- Any custom scripts, configuration or static files stored elsewhere in the installation.
Save the downloaded files in a folder that matches the database export date. If you archive the folder to save space, keep the original file copy until you have checked that the archive opens and contains the expected directories.
WordPress’s file backup documentation lists the site files that should be retained and explains why the database is not included in a normal file download.
Step 3: Store and label the backup safely
Keep the database export and file archive together as one backup set. A simple naming pattern makes it easier to identify matching files later:
wordpress-backups/
2026-11-24/
site-database.sql.gz
site-files.tar.gz
backup-notes.txt
The notes file can record the site name, capture date and time, WordPress version, PHP version, database name (not its password), and the location of the matching files. Do not put secrets or credentials in the notes.
- Keep copies in more than one location, such as a private local drive and a separate off-site storage account.
- Encrypt backups when the storage service or your archive tool supports it, and restrict access to people who need it.
- Keep several recent restore points rather than overwriting the only good copy. WordPress’s handbook suggests keeping 3–5 recent backups in different locations as a general starting point.
- Do not leave SQL dumps, archives or configuration files in a publicly accessible website folder.
- Use clear dates and keep the database export paired with the file archive from the same backup window.
Step 4: Check that the backup files are usable
A successful download message does not prove that a backup can be restored. Perform a basic check before relying on it:
- Confirm that both the database export and the file archive exist.
- Check that neither file is zero bytes and that the sizes are plausible for your site.
- Open or list the file archive and confirm that it contains the expected WordPress directories, especially
wp-content. - Check that the SQL export is not empty and that the export process did not report an error or timeout.
- If you transfer files between systems, consider calculating a SHA-256 checksum before and after the transfer. Our guide explains how to verify a SHA-256 checksum on Windows, macOS and Linux.
These checks catch missing files and transfer problems, but the strongest proof is a successful restore test.
How often should you back up a WordPress site?
Set the schedule according to how often the site changes and how much recent data you can afford to lose. WordPress’s backup handbook gives weekly backups as a general suggestion for smaller, lower-activity sites and daily backups for high-activity sites. It also recommends taking a backup before an upgrade.
- Low-activity blog: A regular weekly backup may be a reasonable starting point, plus a fresh backup before major updates or changes.
- Frequently updated site: Consider daily backups or a schedule that matches how often posts, comments and other data change.
- Store, membership or booking site: Choose a more frequent backup and recovery arrangement that accounts for orders, customer records and transactions. Confirm the host’s recovery point and restore capabilities.
These are planning examples, not a universal rule. If losing even a few minutes of transactions would be unacceptable, ask your host or technical administrator about a suitable recovery-point objective and database backup method.
Step 5: Test a restore on staging or locally
Do not wait for a live-site failure to discover that an archive is incomplete. Restore a copy to a separate staging environment or local installation. Never use your production database as a test target.
- Create a separate destination site and a separate, empty database.
- Restore the backed-up WordPress files to the destination directory.
- Import the matching database export into the destination database. With phpMyAdmin, select the destination database and use the Import tab. With WP-CLI, run the import from the destination installation after confirming that its
wp-config.phppoints to the correct database. - Update the destination’s database credentials in
wp-config.phpif they differ from the original environment. - If the destination uses a different domain or URL, follow a migration procedure that safely handles WordPress URLs and serialized data. Do not use a plain text search-and-replace on the SQL file.
- Restrict access to the test site, discourage search indexing, and disable live email, payment and external integrations before testing.
If you need a separate test environment, see our guide to cloning a WordPress site to a local or staging environment. It covers the extra configuration needed when the destination URL differs from the live site.
Step 6: Restore a live site carefully when recovery is necessary
A live restore can overwrite current files or database records. If you are unsure which backup or database is correct, contact your hosting provider or a WordPress administrator before proceeding.
- Choose the last known good backup and confirm that its database export and file archive belong together.
- Take a copy of the current site state before overwriting anything. Even a broken site may contain recent data that is not present in the older backup.
- Use the host’s restore tool if it supports a full-site restore and you understand which files and database will be replaced.
- For a manual restore, put the site into a maintenance window, restore the WordPress files, then restore/import the matching database. The WordPress handbook describes this typical order.
- Check that
wp-config.phpcontains the correct database name, user, password, host and table prefix for the restored environment. - Clear relevant caches and test the homepage, dashboard, posts, media, forms and important site functions.
- Review logs and monitor the site after it is back online. Keep the backup used for recovery until the restored site has been checked.
Important: A database import can replace existing data depending on the SQL statements in the dump. Confirm the target database before running it. The WP-CLI wp db import reference explains that the command runs the SQL file against the database configured in wp-config.php; it does not create the database for you.
Common WordPress backup mistakes
| Mistake | Why it matters | Better approach |
|---|---|---|
| Saving only the database | The media library, themes and plugins are missing. | Back up both the database and the files. |
| Downloading only the files | Posts, pages, comments and settings are stored in the database. | Export the database separately. |
| Keeping the only copy on the same hosting account | An account or server problem may affect both the site and its backup. | Keep a separate off-site copy. |
| Assuming a scheduled job always succeeds | Storage limits, permissions or timeouts can interrupt a backup. | Check logs, file sizes and restore tests. |
| Never testing a restore | A damaged or incomplete backup may be discovered only during an outage. | Test a restore on a separate environment periodically. |
| Leaving SQL files in the public web directory | Backup files may expose site content or sensitive configuration. | Store them outside the document root with restricted access. |
Frequently asked questions
Is a WordPress database backup enough?
No. It preserves content and database-stored settings, but it does not normally include uploaded media, themes, plugins or other website files. A complete restore needs both parts.
Can I use my hosting provider’s backup instead of making my own?
A host backup can be useful, especially when it offers a tested one-click restore. Check what it includes, its retention period, how to request a restore and whether you can download an independent copy.
Can I restore only the database?
Yes, when the problem is limited to database content and you have identified the correct restore point. A database-only restore does not roll back changed files, themes, plugins or uploads. Take care not to overwrite newer content that should be retained.
Should I test a backup on the live site?
No. Use a separate staging or local environment with its own database. A test import or file replacement on production can overwrite current content and cause downtime.
Does a successful backup message guarantee recovery?
No. Check that both backup components exist and can be opened, then perform a restore test. A backup is dependable only when the required data is present and the recovery process works.
Conclusion
A dependable WordPress backup is a matched copy of the site’s files and database, stored securely and checked before it is needed. Use your host’s backup tools, phpMyAdmin or WP-CLI as appropriate, keep independent copies, and test a restore on a separate environment. A short, repeatable backup routine is far safer than discovering during an outage that the only backup is incomplete.
Official references
- WordPress: Backups
- WordPress: Backing Up Your Database
- WordPress: Backing Up Your WordPress Files
- phpMyAdmin: Import and export
- WP-CLI: wp db export
- WP-CLI: wp db import





