On this page
WordPress runs a huge share of websites, and that is precisely what makes it prone to failures: a plugin update breaks the front end, a conflict between a theme and a plugin damages the dashboard, a compromise injects code into the files, or a mistaken database query wipes out posts. This guide is specific to WordPress, not general backup theory. If you are looking for the theoretical basics (the 3-2-1 rule, media types, general retention strategy), the reference is the general website backup guide; here we focus on what makes backing up WordPress different: its particular structure, its tools (UpdraftPlus and WP-CLI), and the staging environment as a safe arena for backing up, restoring and testing.
What makes backing up WordPress different?
Many site owners treat WordPress as a "folder of files" that just needs archiving. That understanding is incomplete and dangerous. WordPress is a dynamic application that separates code and media (on the file system) from content and settings (in a MySQL database). Every post you write, every setting you configure, every comment, every WooCommerce order and every user lives in the database, not in the files. Conversely, every image you uploaded, every PDF you attached, and the theme and plugins themselves are files. A backup that captures one half without the other gives you either "an empty shell" or "content without a front end."
Three things set WordPress apart from an ordinary static site and deserve attention. First, the database is the heart: deleting the wp_posts table by mistake wipes out all your content even if every file stays intact. Second, the files and the database must be in sync; a files backup from today with a database backup from last week causes conflicts (references to images that don't exist, plugin versions that don't match their tables). Third, URLs are stored embedded inside the database (in wp_options and inside serialized content), so moving the backup to another domain requires a careful replacement operation, not just copy and paste.
Anatomy of a WordPress site: what exactly do you back up?
The following table details the components of WordPress, where each one lives and how important it is in the backup. Keep this table in mind, because it is the map for everything that follows:
| Component | Where it lives | Why you back it up | Essential? |
|---|---|---|---|
| Core files | The root: wp-admin/, wp-includes/ | They can be re-downloaded, but backing them up makes restoring faster | Recommended |
wp-config.php | The site root | Contains the database connection details and the secret keys (salts) | Yes: critical |
| Themes | wp-content/themes/ | Your custom modifications can't be recovered from anywhere else | Yes |
| Plugins | wp-content/plugins/ | Some are paid/custom and hard to get back | Yes |
| Media (uploads) | wp-content/uploads/ | The heaviest part, and it can't be recovered if lost | Yes: critical |
| MySQL database | The MySQL/MariaDB server | Posts, settings, users, orders, comments | Yes: critical |
.htaccess / nginx configuration | The site/server root | Permalinks, redirects and rules | Recommended |
| mu-plugins / drop-ins | wp-content/mu-plugins/, object-cache.php | Must-use plugins and the object cache | As needed |
| Cache and temporary files | wp-content/cache/, .log files | Generated automatically; they bloat the size with no value | No: exclude them |
Why is wp-content the real treasure?
Of everything above, the wp-content folder is the one whose loss is unforgivable. The core files (wp-admin and wp-includes) are identical across all WordPress sites on the same version; you can download them again from wordpress.org in minutes. But wp-content contains everything specific to your site: your theme and its modifications, your plugins and their settings, and above all the uploads/ folder, which holds years of images and media with no copy anywhere else. That is why, if you have to choose because space is tight, your absolute priority is: the database first, then wp-content/uploads, then the rest of wp-content. The core comes last because it can always be re-downloaded.
An expert tip: watch the size of wp-content/uploads over time. It grows constantly, and many failed backup jobs collapse because the folder has grown beyond the plugin's memory limits or execution timeout. If it becomes heavy, that is a strong signal to move from plugin backups to backups with WP-CLI or at the server level.
Ways to back up WordPress: an overview
Before the details, let's map out the available methods. Each method has its place, and the strongest approach in practice is to combine them in layers, as explained in the general website backup guide. The following diagram summarizes the main paths for backing up WordPress:
The table compares the three core WordPress-specific methods:
| Method | How it works | Advantages | Disadvantages | Best for |
|---|---|---|---|---|
| Backup plugin | A plugin that schedules and uploads automatically from inside the dashboard | Easy, automated, one-click restore, off-site uploads | Runs from inside the site, uses PHP resources, struggles on large sites | Beginners, small and mid-size sites |
| WP-CLI / command line | wp db export + tar commands over SSH | Precise, fast, automatable, no PHP limits | Needs SSH access and experience | Technical users, VPS, large sites |
| Host/panel backups | The backup wizard in cPanel/the host's panel, or server snapshots | Built in, no setup, fast recovery | Often on the same server, limited control | Fast recovery as a complementary layer |
Full vs. incremental backups
An important concept that determines how efficient your strategy is. A full backup takes everything every time; it is simple but heavy on large sites. An incremental backup takes only what has changed since the last backup; it is much lighter and faster, but it needs a full backup as a base and makes restoring a little more complicated.
| Type | What it backs up | Space | Speed | Best for |
|---|---|---|---|---|
| Full | All files + the database | Larger | Slower | Small sites, the base backup |
| Incremental | What changed since the last backup | Much smaller | Faster | Large sites, frequent backups |
| Differential | What changed since the last full backup | Medium | Medium | A balance between the two |
UpdraftPlus and some advanced plugins support incremental backups; with WP-CLI you emulate it with rsync for the files (which transfers only what has changed) plus a full database export (the database is usually much smaller than the media, so backing it up in full every time is no problem).
Backing up with plugins: UpdraftPlus step by step
Backup plugins are the easiest gateway for non-technical users. They schedule backups automatically, upload them to a remote destination, and allow one-click restores from inside the dashboard without touching a command line. The best known and most widespread is UpdraftPlus, but it isn't the only one. The table compares the main options:
| Plugin | Strengths | Incremental | Upload destinations | Note |
|---|---|---|---|---|
| UpdraftPlus | The best known, strong free version, easy restores | In the paid version | Drive, Dropbox, S3, R2, FTP | An excellent starting point for most people |
| Duplicator | Excellent for moving and migration (package + installer) | Limited | Multiple (paid version) | The strongest for migration and staging |
| BackWPup | Flexible, supports many destinations | No | S3, FTP, Dropbox and others | Good for mid-size sites |
| Jetpack VaultPress | Real-time backups + activity log | Real-time/continuous | Managed Jetpack storage | Paid, fully managed |
| BlogVault | Independent off-site backups + staging | Yes | Its own storage | Doesn't burden your server (it runs outside it) |
Setting up UpdraftPlus and scheduling
After installing and activating UpdraftPlus, go to Settings → UpdraftPlus Backups. The essential steps:
- On the Settings tab, set the Files backup schedule and the Database backup schedule. They can be different (for example, files weekly and the database daily, because the database changes more often).
- Set the number of backups to keep (retention), for example keeping the last 14 backups. Don't leave it at 1, because you may need an older backup from before a compromise that was discovered late.
- Choose the remote storage destination: Google Drive, Dropbox, Amazon S3 or any S3-compatible storage such as Cloudflare R2. This is what fulfills the off-site requirement; don't leave the backups on the server only.
- Click Save Changes, then authorize the plugin to access the storage destination (through an OAuth flow for services such as Drive).
- Click Backup Now to take the first manual backup and confirm that everything works before relying on the schedule.
A crucial tip about the remote destination: set up the storage destination so its permissions are separate from the site. The idea is that whoever compromises WordPress should not be able to delete your remotely stored backups. Object storage services (S3/R2) let you enable versioning and Object Lock to prevent deletion, which turns your remote backup into a safe haven even if an attacker takes full control of the WordPress dashboard.
Restoring with UpdraftPlus
Restoring couldn't be easier: on the Backup / Restore tab you will see a list of previous backups with their dates. Click Restore next to the backup you want, then choose the components you want to restore (Plugins, Themes, Uploads, Others, Database), and let the plugin handle extracting and importing. For remotely stored backups, you can also click Rescan remote storage to show backups that exist in Drive/S3 but not locally.
The fundamental weakness of all backup plugins is that they run from inside WordPress: they depend on PHP, its memory and its execution timeout. On large sites, the backup or the restore may stall due to a timeout or running out of memory. Worse still, if WordPress breaks down entirely (the white screen of death, a database error), you may not even be able to reach the plugin to restore. That is why you shouldn't make the plugin your only layer; make it a convenient layer on top of a WP-CLI or server backup layer.
Professional backups with WP-CLI
WP-CLI is the official command-line interface for WordPress, and it is the preferred backup tool for technical users and VPS owners: fast, precise, not limited by the web's PHP, and fully automatable through scripts and cron. The prerequisite is SSH access to the server with WP-CLI installed. If you are new to the terminal, the guide SSH basics for beginners is a good starting point before continuing here.
Core WP-CLI backup commands: a reference table
| Command | What it does |
|---|---|
wp core version | Shows the WordPress version (to document it with the backup) |
wp db export backup.sql | Exports the entire database to an SQL file |
wp db export - | gzip > backup.sql.gz | Exports the database and compresses it directly to save space |
wp db import backup.sql | Imports an SQL file into the database (replacing it) |
wp db size --tables | Shows the size of each table (to diagnose bloated tables) |
wp db check / wp db repair | Checks/repairs the database tables |
wp db optimize | Optimizes the database tables before backing up |
wp search-replace 'old' 'new' | Replaces strings safely (handles serialized data) |
wp plugin list --status=active | Documents the plugins active at backup time |
wp config get table_prefix | Shows the table prefix (important when restoring) |
Exporting the database
The heart of a WordPress backup is its database. The basic command is simple and direct:
# Export the entire database to an SQL file with the date in the name
wp db export wp-db-$(date +%F).sqlThe advantage of wp db export over running mysqldump directly is that it reads the connection details automatically from wp-config.php, so you don't need to pass the username and password manually. For large sites, compress the output right away to save space and transfer time:
# Compressed export in one step (suitable for large databases)
wp db export - | gzip > wp-db-$(date +%F).sql.gzFor those who prefer or need mysqldump directly (for example, outside a WordPress environment), here is the equivalent, reading the settings from wp-config.php:
# The equivalent using mysqldump directly
mysqldump -u DB_USER -p'DB_PASSWORD' DB_NAME > wp-db-$(date +%F).sql
# A compressed backup
mysqldump -u DB_USER -p'DB_PASSWORD' DB_NAME | gzip > wp-db-$(date +%F).sql.gzArchiving the files
The second half is the files. Archive the entire site folder, most importantly wp-content and wp-config.php, while excluding the cache and temporary files to reduce the size:
# Archive all site files, excluding the cache and temporary files
tar -czf wp-files-$(date +%F).tar.gz \
--exclude='wp-content/cache' \
--exclude='wp-content/uploads/cache' \
--exclude='*.log' \
-C /var/www/html .If you want a backup focused on what can't be recovered (the lightest and most important part), archive only wp-content and wp-config.php, and re-download the core later when restoring:
# A focused backup: custom content + the configuration file only
tar -czf wp-content-$(date +%F).tar.gz \
-C /var/www/html wp-content wp-config.phpA full backup script, scheduled with cron
Combine the two halves in a single script that takes the database and the files together, in sync, and then uploads them off-site. Here is a practical example you can run:
#!/usr/bin/env bash
set -euo pipefail
SITE="/var/www/html"
DEST="/backups/wp"
STAMP=$(date +%F-%H%M)
mkdir -p "$DEST"
# 1) Export the database, compressed
wp --path="$SITE" db export - | gzip > "$DEST/db-$STAMP.sql.gz"
# 2) Archive the files, excluding the cache
tar -czf "$DEST/files-$STAMP.tar.gz" \
--exclude='wp-content/cache' --exclude='*.log' \
-C "$SITE" .
# 3) Upload off-site to S3-compatible storage (such as R2) with rclone
rclone copy "$DEST" remote:wp-backups/ --include "*-$STAMP.*"
# 4) Clean up local backups older than 7 days
find "$DEST" -type f -mtime +7 -deleteSave the script (for example as /usr/local/bin/wp-backup.sh), make it executable with chmod +x, then schedule it with cron to run at night at a quiet hour:
# Open the cron editor
crontab -e
# Add the following line: a daily backup at 3:15 a.m., with the output logged
15 3 * * * /usr/local/bin/wp-backup.sh >> /var/log/wp-backup.log 2>&1An expert tip: don't just set up cron and forget it. Add a notification on failure (a line that sends an email or a message if the script exits with an error), and check the log file /var/log/wp-backup.log regularly. A silent failure, where cron stopped weeks ago while you think it is running, is the most dangerous kind of backup failure there is.
Huge databases: tricks for large exports
When the database exceeds a few gigabytes (active WooCommerce stores, large membership sites), a normal export becomes slow or fails. Here are some practical tricks:
| Problem | Solution |
|---|---|
| The export is slow/uses a lot of memory | Use wp db export instead of interface tools, and add gzip compression on the fly |
| Bloated temporary tables (transients, sessions) | Clean them up before backing up: wp transient delete --all and wp db optimize |
| Slow queries and table locking | Add --single-transaction/consistent mysqldump options for InnoDB tables |
| A huge SQL file that is hard to move | Split it, or exclude huge non-critical log tables when needed |
| A large import fails with a timeout | Import with wp db import over SSH (not with phpMyAdmin in the browser) |
To diagnose what is weighing down your database before backing up, use:
# Show the size of each table to reveal bloated tables
wp db size --tables --human-readable
# Clean up transients and optimize the tables before exporting
wp transient delete --all
wp db optimizeCleaning up the database before backing up isn't a luxury: wp_options tables bloated with expired transients, or logs left behind by plugins, can double the size of your backup for no reason. For more depth on this, see the guide optimizing the WordPress database if your site suffers from accumulated slowness.
Backing up and restoring through a staging environment
A staging environment is an exact copy of your live site that lives in a separate place (a subdomain, a folder or another server) and is used for experimenting without touching the live site. Many managed WordPress hosts offer staging at the push of a button, and it can also be created through plugins (such as Duplicator or WP Staging). Its role in a backup strategy is central for two reasons: testing restores safely, and testing updates before applying them to the live site.
Why test restores on staging specifically?
The golden rule of backups: a backup you have never tried restoring isn't a backup, it is an assumption. But where do you try it? Not on the live site, of course. A staging environment is the ideal arena: restore the latest backup there, browse the site, check the images, forms, login and the cart (for a store), then delete everything safely with no effect on the live site. This turns restore testing from a risk into a calm routine.
The typical workflow for testing a restore on staging with WP-CLI:
# On staging: restore a full backup for testing
# 1) Extract the backup files into the staging root
tar -xzf files-2026-06-13-0315.tar.gz -C /var/www/staging
# 2) Import the database (after checking the connection details in wp-config)
gunzip < db-2026-06-13-0315.sql.gz | wp --path=/var/www/staging db import -
# 3) Update URLs from the live domain to the staging domain (handles serialized data)
wp --path=/var/www/staging search-replace 'https://example.com' 'https://staging.example.com' --all-tables --skip-columns=guid
# 4) Clear the cache and verify
wp --path=/var/www/staging cache flush
wp --path=/var/www/staging core verify-checksumsThe third step (search-replace) is crucial and specific to WordPress: because URLs are stored inside the database, some of them within serialized data (serialized PHP), a naive text replacement (with sed or an editor) corrupts this data. The wp search-replace command understands serialization and handles it safely, which is why it is the right tool for changing the domain. The --skip-columns=guid option avoids modifying the GUID field, which must stay constant.
The other direction: backing up through staging before updates
Staging isn't only for testing restores; it is also a safety net before risky changes. The recommended workflow: copy the live site to staging, apply the updates (core, plugins, theme) on staging, test that everything works, and then, only once you are sure, apply the updates to the live site (with a safety backup right before). This cuts off the most common disaster: an update breaking the live site in front of your visitors. And when it is time to move changes from staging to the live site, the process overlaps with migration; see the guide migrating a WordPress site without downtime for the details of deploying safely from staging to production.
An expert tip: note that a staging environment is sometimes excluded from scheduled backup jobs, or blocked from search engine indexing, and that is correct. But don't confuse the two: staging is a testing and experimentation tool, not a substitute for an off-site backup. Your real backup must live completely off the server, not on a subdomain on the same server.
Special notes: WordPress Multisite and large sites
A WordPress Multisite network adds a layer of complexity that deserves special attention. In a network, all sites share one core, one set of plugins and one database, but each subsite has its own tables (with a numeric prefix such as wp_2_posts, wp_2_options) and its own upload folder under wp-content/uploads/sites/<ID>/. This means:
| Aspect | On a single site | On Multisite |
|---|---|---|
| Database | One set of wp_* tables | Shared tables + per-site wp_<ID>_* tables |
| Upload folder | wp-content/uploads/ | wp-content/uploads/sites/<ID>/ for each site |
| Restoring one site | A direct full restore | Requires separating the site's tables and upload folder |
wp-config.php | Normal | Contains the network constants (MULTISITE, DOMAIN_CURRENT_SITE) |
To export a whole network's database, the command is the same (wp db export). But to export a single site from the network, target its specific tables:
# List all tables to identify the tables of the site you want (for example, site number 2)
wp db tables 'wp_2_*' --all-tables-with-prefix
# Export the tables of a single subsite from the network
wp db export site-2-$(date +%F).sql --tables=$(wp db tables 'wp_2_*' --all-tables-with-prefix --format=csv)Restoring a single subsite within a network is a sensitive operation: you must import its tables and its upload folder sites/<ID>/ without touching the rest of the network, and you usually need to run search-replace restricted to that site's tables. So if you run a network, document the structure of the tables and sites precisely in your restore guide; improvising here is costly.
Scheduling, off-site storage and the 3-2-1 rule
Everything above serves a single goal: a sound backup in the right place. This is where the 3-2-1 rule comes in, which the general website backup guide explains in detail; very briefly: 3 copies, on 2 different media, with at least 1 of them off the server. The diagram summarizes the idea:
Applying it to WordPress in practice: the first copy is the host's daily snapshot (on the server, for fast recovery), the second is an UpdraftPlus/WP-CLI backup uploaded automatically to remote object storage, and the third is a monthly backup you download and keep locally. The table compares common remote storage destinations for WordPress:
| Destination | Advantages | Disadvantages | Note for WordPress |
|---|---|---|---|
| Google Drive | Easy, reasonable free capacity, familiar | API limits, less automation at scale | Supported directly by UpdraftPlus |
| Amazon S3 | Durable, cheap, versioning + Object Lock | Needs initial setup | The strongest for automation and backup protection |
| Cloudflare R2 | S3-compatible, no egress fees | Newer, fewer options | Economical for heavy media |
| Dropbox | Simple, familiar interface | Space limits that fill up faster | Suitable for small sites |
| FTP/SFTP to another server | Full control, no third party | Manual setup, needs maintenance | Good for those who own a second server |
The decisive WordPress-specific rule: don't leave your backup on the server only. If the server goes down or the hosting account is compromised, the backups go down with it. Enable automatic uploads to a remote destination from day one, and enable versioning on it if possible so it withstands attempts to delete backups by an attacker who has taken over the site.
Combining backups with WordPress security
Backups and security are two sides of the same coin. The backup is your last line of defense when the other layers fail, but it is worthless if you don't manage it with security in mind. Three points tie the two together:
First, backups capture a compromise if there is one. If you take a backup after your site has been injected with malicious code without your knowing, restoring it later brings the malicious code back with it. That is why you need several older backups that let you go back to before the date of the compromise, not just the latest backup. Second, the backup store must be more secure than the site itself: separate permissions, versioning, and no access to it from inside WordPress. Third, after any restore following a compromise, change all the secret keys (the salts in wp-config.php), passwords and authentication.
# Generate new secret keys (salts) in wp-config after a restore following a compromise
wp config shuffle-salts
# Force all users to log in again (invalidates stolen sessions)
wp user session destroy --all --allFor in-depth coverage of the security side (firewalls, permissions, two-factor authentication and malware scanning), see the guide securing a WordPress site, which complements this guide: security reduces the chance of needing a restore, and backups guarantee you survive when disaster strikes despite everything.
Common WordPress backup mistakes
These mistakes recur even among careful site owners, and each of them can completely cancel out the value of your backups:
| Mistake | Why it is dangerous | Solution |
|---|---|---|
| Backing up the files without the database | It won't bring back a working site: all the content is in the database | Back up both halves together, in sync |
Forgetting wp-config.php in the backup | It holds the connection details and keys; the restore breaks without it | Make sure the backup explicitly includes it |
Excluding wp-content/uploads because of its size | You lose years of irreplaceable media | Always back it up, or use WP-CLI/the server for large sites |
| Storing backups on the server only | They go down with a server failure/compromise | Enable off-site uploads (S3/R2/Drive) |
| Relying on a single plugin | It breaks when the site breaks completely | Add a WP-CLI or server backup layer |
Replacing the domain with sed instead of search-replace | It corrupts serialized data | Always use wp search-replace |
| Keeping only one backup | A compromise may be discovered weeks later | Keep several older backups |
| Never testing a restore | A corrupted backup is discovered at the moment of disaster | Test regularly on staging |
| Ignoring cron/plugin failure notifications | A silent failure leaves you exposed | Enable failure alerts and check the logs |
Troubleshooting WordPress backups and restores
When backing up or restoring WordPress specifically runs into trouble, here are the most common problems and their fixes:
| Problem | Likely cause | Solution |
|---|---|---|
| The plugin fails with a timeout | A large site + low PHP limits | Move to WP-CLI, or raise max_execution_time and memory_limit |
| Running out of memory during the backup | wp-content is too heavy for the plugin | Use tar over SSH instead of the plugin |
| Restoring a large database fails | phpMyAdmin/browser upload limits | Import with wp db import over SSH |
| The site works but images are missing | wp-content/uploads wasn't backed up | Make sure the backup includes the uploads folder |
| Broken links after moving to a new domain | Old URLs inside the database | Run wp search-replace for the new domain |
| An "Error establishing a database connection" after restoring | Wrong connection details in wp-config.php | Correct the database name/user/host and the prefix |
| Garbled content/broken characters after importing | An encoding mismatch (charset/collation) | Export/import with a matching utf8mb4 encoding |
| The restore succeeded but the plugins are broken | The core version doesn't match the plugins | Restore the matching core or update carefully |
If you run into general WordPress errors after restoring (the white screen of death, a 500 error, permalink problems), the guide fixing common WordPress errors covers diagnosing and fixing them step by step. And to understand WordPress as a whole, and where backups fit into its management cycle, the complete WordPress guide remains the comprehensive reference.
A WordPress backup checklist
Use this list as a yardstick for how complete your strategy is. Any item you can't tick represents a gap:
| Item | Done? | Why it matters |
|---|---|---|
| The backup includes the complete MySQL database | ☐ | The heart of the site: all the content is in it |
The backup includes wp-content and wp-config.php | ☐ | Your theme, plugins, media and settings |
| At least one copy off-site | ☐ | Survives a server failure/compromise |
| Automatic uploads enabled (Drive/S3/R2) | ☐ | No reliance on the server alone |
| Backups are scheduled (plugin or cron) | ☐ | No reliance on human memory |
| A backup before every update (core/plugin/theme) | ☐ | A safety net for risky updates |
| Several older backups kept | ☐ | A compromise may be discovered late |
| The backup store is protected with separate permissions | ☐ | Prevents an attacker from deleting your backups |
| A notification on backup failure + log checks | ☐ | Reveals silent failures |
| Regular restore testing on staging | ☐ | Proves that the backup can be restored |
Conclusion
Backing up WordPress isn't a task to put off; it is an insurance policy on your digital business. The WordPress-specific principles are clear: back up the MySQL database together with wp-content and wp-config.php, in sync, and choose your tool according to your level: UpdraftPlus and similar plugins for beginners and mid-size sites, and WP-CLI with cron and rsync for technical users and large sites. Enable off-site uploads from day one in line with the 3-2-1 rule, and keep several older backups to save you from a compromise discovered late. But the real deciding factor remains a single item: testing restores in a staging environment regularly. A backup that has never been tried is a comfortable illusion until it is exposed at the moment of disaster. Apply the checklist, automate what can be automated, and make restore testing on staging a monthly habit.
When choosing managed WordPress hosting, look for automatic backups and one-click staging, because these features lighten this whole burden from the start and give you a ready-made safety net without complicated setup.
Frequently asked questions
What should a full WordPress backup include?
Two inseparable parts: the files (most importantly wp-content, with all its themes, plugins and media, along with wp-config.php) and the complete MySQL database. The files alone give you an empty shell, and the database alone gives you content without a front end, and the two must be in sync in time to avoid conflicts.
Is UpdraftPlus enough on its own to protect my site? It is an excellent starting point for beginners and small and mid-size sites, especially with off-site uploads to Drive or S3/R2 enabled and several copies kept. But it runs from inside WordPress, so it may struggle on large sites or become unavailable if the site goes down completely. Don't make it your only layer; add a WP-CLI layer or server backups for critical sites.
How do I back up WordPress with WP-CLI?
Two steps: export the database with wp db export wp-db.sql (or compressed: wp db export - | gzip > wp-db.sql.gz), and archive the files with tar -czf wp-files.tar.gz -C /var/www/html . while excluding the cache. Then combine them in a script and schedule it with cron, with an off-site upload. You restore with wp db import and by extracting the archive.
Why should I use wp search-replace instead of a normal find and replace when changing the domain?
Because WordPress stores some data in serialized form (serialized PHP), which includes string lengths. A naive text replacement (sed or an editor) changes the text without updating the lengths, so it corrupts the data and settings break. The wp search-replace command understands serialization and handles it safely, which is why it is the right tool when moving a site to a new domain.
How do I test that my backup can actually be restored?
Restore it in a separate staging environment, not on the live site: extract the files, import the database, run wp search-replace to change the domain, then browse the pages, images, forms, login and the cart (for a store). Repeat the test monthly for critical sites and every few months for others. An untested backup is not a backup.
How do I handle backing up a huge WordPress database?
Clean up first (wp transient delete --all and wp db optimize), use wp db export with immediate gzip compression instead of browser tools, diagnose bloated tables with wp db size --tables, and always import with wp db import over SSH, not phpMyAdmin (which is limited by browser upload limits and timeouts).
How is backing up different on WordPress Multisite?
The network shares one core, one set of plugins and one database, but each subsite has its own tables (wp_<ID>_*) and its own upload folder, uploads/sites/<ID>/. Exporting the whole network works as usual (wp db export), but restoring a single subsite requires separating its tables and upload folder and running search-replace restricted to its tables, a sensitive operation that deserves careful documentation.
Do I need a backup before every update in WordPress? Yes, strongly. Updates (core, plugins, themes) are the most common cause of WordPress failures. Take a full backup before any update, and preferably test the update first on staging, then apply it to the live site. This "safety copy before the leap" is far cheaper than rebuilding a site broken by a failed update.
My site was hacked: which backup do I restore, and what do I do afterwards?
Restore a clean backup from before the date of the compromise, not the latest backup (which may contain the malicious code), which is why you need several older copies. After restoring, regenerate the secret keys with wp config shuffle-salts, invalidate all sessions with wp user session destroy --all --all, change all passwords, and investigate the cause of the vulnerability before putting the site back online.
Sources
Frequently asked questions
What should a full WordPress backup include?
Two inseparable parts: the files (most importantly wp-content, with all its themes, plugins and media, along with wp-config.php) and the complete MySQL database. The files alone give you an empty shell, and the database alone gives you content without a front end, and the two must be in sync in time to avoid conflicts.
Is UpdraftPlus enough on its own to protect my site?
It is an excellent starting point for beginners and small and mid-size sites, especially with off-site uploads to Drive or S3/R2 enabled and several copies kept. But it runs from inside WordPress, so it may struggle on large sites or become unavailable if the site goes down completely. Don't make it your only layer; add a WP-CLI layer or server backups for critical sites.
How do I back up WordPress with WP-CLI?
Two steps: export the database with wp db export wp-db.sql (or compressed: wp db export - | gzip > wp-db.sql.gz), and archive the files with tar -czf wp-files.tar.gz -C /var/www/html . while excluding the cache. Then combine them in a script and schedule it with cron, with an off-site upload. You restore with wp db import and by extracting the archive.
Why should I use wp search-replace instead of a normal find and replace when changing the domain?
Because WordPress stores some data in serialized form (serialized PHP), which includes string lengths. A naive text replacement (sed or an editor) changes the text without updating the lengths, so it corrupts the data and settings break. The wp search-replace command understands serialization and handles it safely, which is why it is the right tool when moving a site to a new domain.
How do I test that my backup can actually be restored?
Restore it in a separate staging environment, not on the live site: extract the files, import the database, run wp search-replace to change the domain, then browse the pages, images, forms, login and the cart (for a store). Repeat the test monthly for critical sites and every few months for others. An untested backup is not a backup.
How do I handle backing up a huge WordPress database?
Clean up first (wp transient delete --all and wp db optimize), use wp db export with immediate gzip compression instead of browser tools, diagnose bloated tables with wp db size --tables, and always import with wp db import over SSH, not phpMyAdmin (which is limited by browser upload limits and timeouts).
How is backing up different on WordPress Multisite?
The network shares one core, one set of plugins and one database, but each subsite has its own tables (wp_<ID>_) and its own upload folder, uploads/sites/<ID>/. Exporting the whole network works as usual (wp db export), but restoring a single subsite requires separating its tables and upload folder and running search-replace restricted to its tables, a sensitive operation that deserves careful documentation.
Do I need a backup before every update in WordPress?
Yes, strongly. Updates (core, plugins, themes) are the most common cause of WordPress failures. Take a full backup before any update, and preferably test the update first on staging, then apply it to the live site. This "safety copy before the leap" is far cheaper than rebuilding a site broken by a failed update.
My site was hacked: which backup do I restore, and what do I do afterwards?
Restore a clean backup from before the date of the compromise, not the latest backup (which may contain the malicious code), which is why you need several older copies. After restoring, regenerate the secret keys with wp config shuffle-salts, invalidate all sessions with wp user session destroy --all --all, change all passwords, and investigate the cause of the vulnerability before putting the site back online.