Skip to content

How to Back Up a WordPress Site (and Actually Restore It)

Learn how to back up a WordPress site the right way: files and database, plugin, host snapshot or WP-CLI, a 3-2-1 offsite plan and a tested restore.

By Devma Hosting Team · · 10 min read

External hard drives and a small network storage device with green status lights on a lamp-lit desk beside a closed laptop and an open notebook.

To back up a WordPress site properly, you need two things: a copy of every file in your WordPress directory and an export of the database. You can make both with a backup plugin, your host's snapshot tool or WP-CLI, but a backup only really counts once a copy sits offsite and you have proven you can restore it. This guide shows how to back up a WordPress site with each method, where to keep the copies, and how to run a test restore before you ever need one.

Key takeaways

  • A complete WordPress backup has two parts: the database (posts, pages, users, settings, orders) and the files (core, themes, plugins, uploads, wp-config.php.htaccess). Neither one alone can rebuild your site.
  • The official WordPress documentation recommends backing up the database first, then the files, and making a full backup before every core, plugin or theme update.
  • Follow the 3-2-1 rule: three copies of your data, on two different types of storage, with one copy kept offsite, away from your web host.
  • Match the schedule to how often your site changes: weekly for a brochure site, daily for an active blog, hourly or real-time for a WooCommerce store.
  • A backup is only proven when you have restored it to a staging site, checked that it works, and timed how long the restore took.

What does a full WordPress backup include?

A WordPress site lives in two places, and you need both.

The database holds almost everything you type into wp-admin: posts, pages, comments, users, menus, widget and plugin settings, and, on a store, orders and customers.

The files are, in the words of the official WordPress backup guide, everything in your WordPress directory: "WordPress core, themes, plugins, uploads, wp-config.php.htaccess, etc." The uploads folder is usually the largest part, and it is the part you cannot download again from anywhere.

The same guide recommends backing up the database first, then the files. Many plugin tutorials ignore the order, but it is a sensible habit: if anything changes during the backup, your database will not reference uploads that are missing from the file archive.

One warning before you start: wp-config.php contains your database password and security keys. Treat any backup that includes it as sensitive data. Encrypt it or restrict access to it, and never leave it in a public web folder.

How to back up a WordPress site: three methods compared

The WordPress docs list three broad approaches: backup tools provided by your host, phpMyAdmin, and backup plugins from the Plugin Directory. In practice, most site owners use a plugin, a host snapshot, a command-line method, or a combination.

Method Best for Strengths Watch out for
Backup plugin Most small sites, non-technical owners Easy schedules, sends copies to cloud storage, restore from wp-admin Runs inside WordPress, so a broken site can break the backup tool too
Host snapshots Everyone, as a first layer Runs outside WordPress, no setup, fast restores Usually stored with the same provider, retention varies
WP-CLI and mysqldump Developers, VPS users, agencies Full control, scriptable, standard file formats Needs shell access and some care with flags

Option 1: Use a backup plugin

Plugins such as UpdraftPlus and Jetpack VaultPress Backup are widely used. Their features and pricing change over time, so check the current plugin page before you choose. Whatever you pick, look for:

  • Separate schedules for the database and the files
  • Remote destinations (S3-compatible storage, Google Drive, Dropbox or similar)
  • Retention settings so old copies are pruned automatically
  • Backups in standard formats (.zip or .tar archives and .sql files) so you can restore by hand if wp-admin is down
  • Encryption, or at least support for private storage

To set one up:

  1. Install and activate the plugin.
  2. Connect your remote storage account, ideally with credentials that only have access to the backup bucket or folder.
  3. Set the database and file schedules and the number of copies to keep.
  4. Run a manual backup and confirm the files actually appear in remote storage.
  5. Download one backup and open it. Check that it contains an .sql file and your wp-content/uploads folder.

Option 2: Use your host's snapshots

Host-level backups run on the server, outside WordPress, so they still work when a bad plugin update has taken down wp-admin. Retention periods vary a lot between hosts and plans. Check how often snapshots run, how long they are kept, whether you can restore just the database or a single folder, and whether you can download a copy.

The catch: these snapshots are usually stored with the same provider. They are a great copy number two, but they are not your offsite copy. If you are comparing plans, our WordPress Hosting page lists what is included, and our guide to VPS vs shared hosting vs managed WordPress explains how backup responsibilities shift between plan types.

Option 3: Back up with WP-CLI and mysqldump

If you have shell access, for example on a VPS, WP-CLI gives you fast, scriptable backups. The wp db commands read the database credentials from wp-config.php, so you do not need to type passwords.

# Run from the WordPress root (the folder containing wp-config.php)
cd /var/www/example.com/public_html
mkdir -p ~/backups

# 1. Database first, compressed on the fly
wp db export - | gzip > ~/backups/db-$(date +%F).sql.gz

# 2. Then the files
tar -czf ~/backups/files-$(date +%F).tar.gz -C /var/www/example.com public_html

Note that ~/backups sits outside the public web root, so nobody can download your archives through a browser. According to the wp db export documentation, writing to - sends the dump to standard output so you can pipe it, --tables= and --exclude_tables= let you choose tables, and other options are passed through to the underlying dump tool.

Without WP-CLI, you can call mysqldump directly:

mysqldump --single-transaction --quick -u DB_USER -p DB_NAME | gzip > ~/backups/db-$(date +%F).sql.gz

What the flags do, per the MySQL reference manual:

  • --single-transaction produces a consistent backup without locking the site, but only InnoDB tables are dumped in a consistent state. MyISAM tables can still change mid-dump.
  • --quick streams rows one at a time, which helps with large tables.
  • --single-transaction and --lock-tables cannot be combined.

Modern WordPress installs create InnoDB tables, but older sites sometimes still have MyISAM ones. You can check with:

wp db query "SELECT TABLE_NAME, ENGINE FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE();"

On some servers running MariaDB, the dump tool may be installed under the name mariadb-dump. If mysqldump is not found, check which client tools your server provides.

To automate the database backup, add a cron job. Remember that % must be escaped in crontab:

30 2 * * * cd /var/www/example.com/public_html && wp db export - | gzip > $HOME/backups/db-$(date +\%F).sql.gz

You may need the full path to wp in cron, since cron runs with a minimal environment.

Where should you store WordPress backups? Use the 3-2-1 rule

The 3-2-1 rule is the standard baseline: three copies of your data, on two different types of media, with one copy offsite. For a WordPress site, it maps like this:

Copy What it is Protects against
1 The live site Nothing on its own
2 Host snapshot or plugin archive on the server Bad updates, accidental deletions
3 Offsite storage you control (S3-compatible bucket, Google Drive, a local disk) Server failure, account problems, host outages

Some security guidance now goes further, with variants such as 3-2-1-1-0. These add an immutable or air-gapped copy and require restore tests to complete without errors. That extra layer matters because attackers who get into a site or a hosting account sometimes delete the backups too.

Practical ways to harden the offsite copy:

  • Use separate credentials for backup storage, not your main cloud account login.
  • Where your storage supports it, give the backup tool permission to write but not delete.
  • Turn on object versioning or object lock so old copies survive even if newer ones are overwritten.
  • Encrypt archives that contain wp-config.php or customer data.

With a tool like rclone, a nightly rclone copy ~/backups remote:my-site-backups after the backup job is enough to get copy number three off the server.

How often should you back up a WordPress site?

The right schedule depends on how much new data you would lose between backups. These are sensible starting points, not hard rules:

Site type Database Files Keep for
Brochure or portfolio, rarely updated Weekly Weekly or monthly 4 to 8 weeks
Blog posting several times a week Daily Weekly (uploads daily) 30 days
WooCommerce or membership site Hourly or real-time Daily 30 to 90 days

For every site, take a manual backup before core, plugin or theme updates. The WordPress upgrade docs are blunt about it: without a backup of the whole site and database made beforehand, "a successful rollback is near impossible."

Retention matters as much as frequency. Hacks are often discovered days or weeks after they happen. If you only keep seven days of backups, every copy you have may already contain the malware.

How to test a WordPress restore, step by step

This is the part most people skip, and it is the only way to know your backups work. Do it on a copy, never on the live site.

  1. Create a test environment. Use a staging subdomain, a spare hosting account, or a local tool such as Local or wp-env. Block search engines and put it behind a password.

  2. Restore the files. Upload and extract the file archive into the empty web root:

    tar -xzf files-2026-11-18.tar.gz --strip-components=1
    
  3. Point wp-config.php at the staging database. Edit DB_NAME, DB_USER, DB_PASSWORD and DB_HOST to match the new, empty database. Restore into a database with no tables. The WordPress database backup page gives the same advice for its quick phpMyAdmin method (that page is otherwise outdated, so use it for concepts only).

  4. Import the database.

    gunzip db-2026-11-18.sql.gz
    wp db import db-2026-11-18.sql
    
  5. Update the URLs safely. WordPress stores some data in serialized form, so never run find and replace on the .sql file in a text editor. Use wp search-replace, preview first with --dry-run, and leave post GUIDs alone:

    wp search-replace 'https://example.com' 'https://staging.example.com' --skip-columns=guid --dry-run
    wp search-replace 'https://example.com' 'https://staging.example.com' --skip-columns=guid
    

    Add --network on multisite. Avoid --regex unless you need it, since the docs warn it is about 15 to 20 times slower.

  6. Check the site. Go through this list:

    • You can log in to wp-admin.
    • The media library shows images, not broken thumbnails.
    • Permalinks work (re-save them under Settings, Permalinks if pages return 404).
    • Contact forms submit.
    • On a store, recent orders and customer accounts are present.
    • The newest post or order is there. Its date tells you how much data a real restore would lose.
  7. Write down how long it took. That number is your realistic recovery time. If it is too long for your business, change your backup method or hosting before a crisis, not during one.

  8. Repeat regularly. Run a test restore every quarter and after any big change, such as a new host, a major plugin, or a switch in backup tools.

The same restore process is the core of moving a site. If you are planning a move, our guide to migrating WordPress to a new host with zero downtime builds on these steps.

Rolling back the live site

If you need to restore production after a failed update, the documented approach is: delete every WordPress file except wp-config.php, upload the backed-up files, then restore the database backup. Take a fresh backup of the broken state first, in case you need anything from it later.

Common WordPress backup mistakes to avoid

  • Backing up only half the site. Files without the database, or the database without uploads, will not rebuild anything.
  • Keeping every copy on the same server or with the same host. One account problem can take out the site and its backups together.
  • Leaving out wp-config.php or .htaccess. Both are part of a full backup, and both are easy to forget in manual scripts.
  • Storing archives in a public folder. A .zip in public_html can be downloaded by anyone who guesses the name, along with your database password.
  • Running mysqldump without --single-transaction on a busy site. You risk locked tables or an inconsistent dump.
  • Editing SQL files by hand to change domains. This corrupts serialized data. Use wp search-replace.
  • Retention that is too short. Make sure you can go back further than the time it might take to notice a hack. Our WordPress security checklist covers the other half of that problem: noticing sooner.
  • Never testing a restore. An untested backup is a hope, not a plan.

Make backups part of your WordPress hosting setup

Good backups combine three layers: a host snapshot for quick recovery, an automated plugin or WP-CLI job that copies data offsite, and a test restore on a schedule. If you would rather not manage all of that yourself, see Devma Hosting's Website Maintenance page for ongoing site care. Our Security & AI Bot Protection page covers ways to reduce the chance you will ever need a restore. Either way, run your first test restore this week. It is the only backup check that really counts.

Frequently asked questions

Does my web host's backup count, or do I still need a plugin?

A host backup is a good first layer because it runs outside WordPress and keeps working even if your site is broken. It is usually stored with the same provider, so it does not count as your offsite copy. Add a second backup that lands in storage you control, through a plugin, WP-CLI or a script.

Can I restore just the WordPress database without overwriting my files?

Yes. If only content or settings went wrong, you can import a database backup on its own with phpMyAdmin or wp db import and leave the files untouched. Make sure the database backup and the installed plugin versions are roughly from the same point in time, because some plugins change their table structure during updates.

How many WordPress backups should I keep?

Keep enough history to go back to a point before a problem started, not just yesterday. Malware and data errors are often noticed days or weeks later, so a 30-day window is a sensible minimum for most active sites, with longer retention for stores. Keep at least one copy offsite and ideally versioned so it cannot be deleted from a compromised account.

Should WordPress backups be encrypted?

Yes, or at least strictly access-controlled. A full backup includes wp-config.php, which holds your database password and secret keys, plus user data and possibly customer orders. Store archives outside the public web directory and use encryption or private, restricted storage for offsite copies.

Abstract blue swirling shapes with light reflections

Ready when you are.

Pick a plan and launch today, or tell us what you run and we will size it with you.

Devma Hosting

AI assistant · replies in seconds

Hi there.
How can we help?

Ask about plans, moving your site, email or security. Answers come from our own guides, and a person is one tap away.

  • Message us on WhatsApp