← All posts

WordPress backups: what to back up, where to keep it, and how to prove you can actually restore

“The site is backed up” isn't enough. What a WordPress backup must include, the questions to ask your host, where to store copies, a complete WP-CLI script and, above all, how to test a restore before you need one.

WordPress backups: what to back up, where to keep it, and how to prove you can actually restore

Key points

  • A useful backup includes the database AND the wp-content folder, lives off the server, and goes back several weeks.
  • The only proof that a backup works is a successful restore: run one on a staging site at least once a quarter.
  • Decide upfront how much data you can afford to lose and how long the site can be down: those two answers set the frequency and the tooling.

When a site goes down, whether it’s a botched update, a hack or someone deleting the wrong thing, the first question is always the same: “do we have a backup?” And the answer is nearly always “yes, the host does that”. That’s usually the moment people discover the latest backup is three weeks old, that it only covers the files, that it sits on the same server as the hacked site, or that nobody knows how to put it back. This guide is for site owners and developers alike: what a WordPress backup needs to contain, the questions worth asking your provider, where copies should live, a full script if you run your own server, and the step almost everyone skips: proving you can restore.

What a WordPress backup has to include

A WordPress site is two things that only work together:

  • The database: posts, pages, settings, user accounts, shop orders, form entries if a plugin stores them. Anything typed into the dashboard ends up here.
  • The wp-content folder: the theme, the plugins and, crucially, uploads, which holds every image and document added since the site went live. It’s usually the heaviest part and the hardest to replace.
  • Configuration files: wp-config.php (database access, security keys, custom constants) and, on Apache, .htaccess, which may hold years’ worth of redirects.

WordPress core (wp-admin and wp-includes) doesn’t need backing up: one command downloads it again, as long as you know the exact version. That’s why our script records it every time.

The most common trap we come across is a backup that only has one half. A database without images gives you a site full of broken thumbnails. Files without the database give you a blank WordPress with a nice theme. The second trap: the database is backed up daily, but uploads only goes into a weekly job, and nobody knows.

Also think about what lives outside WordPress and would vanish with the server: scheduled tasks, custom PHP or Nginx settings, certificates, and email if your mailboxes are with the same host. These don’t all need nightly backups, but they should be written down somewhere.

Questions to ask your host or agency

Before choosing any tool, settle two targets. IT people call them RPO and RTO; in plain terms:

  • How much data can you afford to lose? For a brochure site edited once a month, losing a day is irrelevant. For a shop taking orders all day, or a site collecting sign-ups, every lost hour is customers you’ll have to chase.
  • How long can the site be down? Half a day is fine for some businesses and unthinkable for others.

Those answers decide how often you back up and what level of service you need. Then, here are the questions we always ask when we take over a site. You can send them to your host yourself:

  • What’s included? Database and files, or just one?
  • How often, and how far back? Daily backups kept for seven days won’t help with a hack you find three weeks later. On the sites we maintain we aim for at least thirty days of history.
  • Where are the copies stored? Same server, same data centre, or somewhere else?
  • Who can restore, and how? Self-service from a control panel, or via a support ticket (with what turnaround)?
  • Can you restore just one piece? Only the database, or a single file, without overwriting the whole site.
  • Can you download a backup? Essential the day you change host, or if your account is ever suspended.

If the answers are vague, treat the host’s backups as a safety net rather than your strategy. Hosting backups are often very good, but they’re tied to your account and your contract: they aren’t an independent copy.

Where to store backups: off the server, and out of reach

The classic rule is “3-2-1”: three copies of your data, on two different kinds of storage, one of them off-site. For a WordPress site that’s simply the live site, the host’s backup, and an independent copy on external storage, such as S3-compatible object storage with a different provider.

Three mistakes keep turning up on sites we inherit:

  • Backup archives inside the website folder. Some plugins drop their ZIP files in wp-content. If that folder isn’t protected, anyone who knows or guesses the filename can download your whole site, database and hashed passwords included. We still find these during security audits.
  • A single copy on the same server. If the disk fails or the server is compromised, the backup goes with it.
  • External storage the site can write to and delete from. An attacker who takes over the server finds the storage credentials and wipes your backups. Use an access key that can only add files, and turn on versioning or object lock on the bucket so a deletion or overwrite can still be undone.

Plan retention in tiers rather than keeping everything forever: say, the last seven days, then one a week for the month, then one a month for the year. Most object storage can apply lifecycle rules like that automatically, which also stops the bill from quietly creeping up.

Automating backups with WP-CLI

If your site runs on a server or VPS you manage, a short script beats most plugins and adds no weight to WordPress. This is the one we start from on our projects. It uses WP-CLI (WordPress’s command-line tool) and rclone, which can push files to pretty much any storage provider.

#!/usr/bin/env bash
# Nightly WordPress backup (database + files) to off-site storage
set -euo pipefail

SITE=/var/www/mysite              # folder containing wp-config.php
DEST=/var/backups/mysite          # local staging folder, OUTSIDE the web root
REMOTE="backups:mysite"           # remote storage configured in rclone
STAMP=$(date +%F-%H%M)

mkdir -p "$DEST"
cd "$SITE"

# 1. WordPress version (so you can reinstall the exact same core)
wp core version > "$DEST/version-$STAMP.txt"

# 2. Database: consistent export without locking the site
wp db export "$DEST/db-$STAMP.sql" --single-transaction --quick
gzip "$DEST/db-$STAMP.sql"

# 3. Files: wp-content and configuration (core can be downloaded again)
#    On Nginx, drop .htaccess from the list.
tar -czf "$DEST/files-$STAMP.tar.gz" 
    --exclude='wp-content/cache' --exclude='wp-content/upgrade' 
    wp-content wp-config.php .htaccess

# 4. Copy off the server, then clean up local copies older than 3 days
rclone copy "$DEST" "$REMOTE/$STAMP" --include "*-$STAMP.*"
find "$DEST" -type f -mtime +3 -delete

A few choices worth explaining:

  • --single-transaction takes a consistent snapshot of the database without locking it, so the site keeps running during the export (this applies to InnoDB tables, the default on any recent install).
  • The staging folder sits outside the public web root, so an archive is never reachable from the web.
  • set -euo pipefail stops at the first error. Without it, a failed database export can slip by and the script proudly uploads an empty file.
  • Cache and temporary update folders are excluded: they rebuild themselves and can be large.

All that’s left is running it nightly:

# crontab -e: every day at 03:17 (avoid the top of the hour, everyone uses it)
17 3 * * * /usr/local/bin/wp-backup.sh >> /var/log/wp-backup.log 2>&1

One last point people forget: a failed backup must alert someone. A cron job that has been failing silently for two months is the story we hear most often. At the very least, get the log emailed on error; better still, use a monitoring service that expects a ping from your script after each successful run and warns you when it doesn’t arrive.

If you’re on shared hosting without SSH, a well-established backup plugin configured to send copies to external storage (not keep them on the server) does the job perfectly well. The same rules apply: database and files, external storage, alerts, and a restore test.

The restore test: the only proof it works

Hardly anyone does this, yet it’s the only step that really matters. A backup you’ve never restored is an assumption. On the sites we take over, the first restore test very often turns something up: an incomplete archive, a database exported with the wrong character set, a missing config file, or just a procedure nobody actually knows.

The idea is simple: restore last night’s backup onto a staging site, never onto production. If you already have a staging environment, this is exactly what it’s for. Here’s the process, again with WP-CLI:

# Test restore into an empty staging folder
cd /var/www/staging
rclone copy "backups:mysite/2026-11-17-0317" ./restore

# 1. Same WordPress core as production
wp core download --version="$(cat restore/version-*.txt)" --skip-content

# 2. Files (wp-content, wp-config.php, .htaccess)
tar -xzf restore/files-*.tar.gz
#    -> edit wp-config.php: STAGING database credentials

# 3. Database
wp db reset --yes
gunzip -c restore/db-*.sql.gz | wp db import -

# 4. Fix the URL and keep search engines out
wp search-replace 'https://www.mysite.com' 'https://staging.mysite.com' 
    --all-tables --skip-columns=guid
wp option update blog_public 0
wp cache flush

Two commands deserve a closer look. wp search-replace swaps the site address throughout the database, including inside serialised data, where a plain SQL replace would break things; the guid column is skipped because it’s a permanent identifier for each post. And blog_public 0 asks search engines not to index the copy, which would otherwise be duplicate content.

Then check. The home page loading is a good sign, but it isn’t enough. Compare a few numbers with production:

# Compare a few counters between production and the restored copy
wp post list --post_type=post --post_status=publish --format=count
wp post list --post_type=page --post_status=publish --format=count
wp user list --format=count
wp plugin list --status=active --field=name | sort
# And media: the file count should be in the same ballpark
find wp-content/uploads -type f | wc -l

Then click around: the home page, an old post with its images (that’s where you find out whether uploads is complete), logging into the dashboard, a form, search. For a shop, open the most recent order and make sure it’s from yesterday.

Finally, time the whole thing and write every step into a shared document. That measured time is your real recovery time; if it isn’t acceptable, now is the moment to find out. And on the day of an outage, whoever is on call only has to follow the steps. We run this test at least once a quarter, and every time the host or backup tool changes.

Special cases: online shops, large sites and hacks

The process above covers most sites. Three situations need more thought.

A WooCommerce shop or a site taking sign-ups. Restoring last night’s backup over production wipes out everything since: orders, new accounts, payments received. Before restoring, export what was created after the backup, or restore alongside and recover items one by one. On these sites we also back up the database more often (hourly, for example), because that’s what changes constantly, while files barely move.

A media-heavy site. Once uploads runs to tens of gigabytes, building a full archive every night gets slow and expensive. Switch to incremental backups that only send new or changed files: rclone sync to versioned storage, or a dedicated tool such as restic, which deduplicates and encrypts. Keep exporting the full database each time; it’s small by comparison.

After a hack. Restoring the latest backup on reflex can put the malicious code straight back, because the break-in often happened well before anyone noticed. This is where a long history earns its keep. Work out when the intrusion happened (server logs, modification dates of suspicious files), pick a backup from before then, and re-apply legitimate content published since. Change every password and the keys in wp-config.php too, or the attacker walks back in the same way.

FAQ

My host already backs up my site. Isn’t that enough?

It’s a good start, but it isn’t an independent copy: it depends on your account and contract, and retention can be short. Add a regular copy to external storage you control, and check at least once that you can restore from each.

How often should I back up a WordPress site?

It depends on how much data you can afford to lose. Daily suits most brochure sites; a shop or a site collecting sign-ups deserves database backups several times a day. Files change less and can stay daily.

How long should backups be kept?

Long enough to go back before a problem you only spot later, a hack in particular. We aim for at least thirty days, in tiers: daily for a week, weekly for a month, monthly beyond that.

Can a backup plugin slow my site down?

While it runs, yes, especially on shared hosting with lots of media. Schedule it overnight, exclude cache and temporary folders, and move to incremental file backups once the site gets large.

Not sure your site could be restored tomorrow? We audit your backups, set up a strategy that fits, and test restores as part of our WordPress maintenance plans.

Share LinkedIn Facebook X WhatsApp
</>

webtestudio

Web agency: custom WordPress sites, premium themes and SaaS software.

Discuss your project →