How to back up a WordPress site properly (and prove it works)

Back up the database and wp-content daily, keep copies off-site for 30 days, and test a restore. The setup, a WP-CLI script and the mistakes to avoid.

By Sohail Hussain21 November 20265 min read

A proper WordPress backup has four parts. It copies the database and the wp-content folder, plus wp-config.php and .htaccess. It runs automatically, on a schedule that matches how often the site changes. It is stored somewhere other than your hosting account. And it has been restored successfully at least once. Most sites have the first part. Few have the last, and a backup that has never been restored is a hope, not a plan.

This is the setup we run on WordPress sites under our website care and maintenance plans. You can set up the same thing yourself in an afternoon.

What does a WordPress backup need to include?

Two things, and you need both to restore a site:

  • The database. Every post, page, setting, user, form entry and order. Without it you have a theme and no content.
  • The files. The wp-content folder holds your uploads (every image and document), themes and plugins. wp-config.php holds the database connection and security keys. .htaccess holds rewrite rules and any redirects added there.

WordPress core files (wp-admin and wp-includes) can always be downloaded fresh, so they are optional. Including them costs little and makes a restore simpler, so most tools do.

Exclude cache folders and old backup files stored inside wp-content. A plugin that saves its archives into wp-content and then backs up that folder produces archives that grow with every run.

How often should you back up, and for how long?

Match the schedule to how much work you could bear to lose:

SiteDatabaseFilesKeep copies for
Brochure site, edited monthlyDailyWeekly30 days
Site with a blog or form entriesDailyDaily30 days
WooCommerce store or membership siteHourly or real-timeDaily30 to 90 days

The retention column matters more than it looks. Hacks and accidental deletions are often noticed weeks later, and a schedule that keeps only seven days may hold nothing but bad copies. The official WordPress backup guide recommends keeping several recent backups in different places for the same reason.

Take an extra backup before every update, migration or large content change.

Which backup method should you use?

MethodWhere copies liveRestore effortCost (as of October 2026)Weak point
Host backupsUsually the host's own storageOne click, if the host is healthyOften includedLost if the account is lost, suspended or compromised
Backup plugin (UpdraftPlus, WPvivid and similar)Cloud storage you connectModerate; usually needs a working WordPress to restore fromFree, or roughly $50 to $100 a year for premium versionsRuns inside WordPress, so a broken site can break the backup
Managed backup service (BlogVault, Jetpack VaultPress Backup and similar)The service's serversEasy; can restore from outside WordPressRoughly $50 to $200 a year per siteAnother subscription and vendor
WP-CLI script and cronWherever you send itManual; needs SSHStorage onlyNeeds someone comfortable on a server

The setup we recommend uses two. Host backups give quick rollbacks. A second, independent copy goes to storage the host cannot touch, such as an Amazon S3, Backblaze B2 or Google Drive account in the company's own name. Give that storage its own login, so an attacker who gets into the hosting account cannot delete the backups as well.

How do you set up backups with WP-CLI?

If you have SSH access, a short script does the job without a plugin. It uses wp db export, which writes the database to standard output when given -, as the WP-CLI documentation describes:

bash
#!/bin/sh
set -e
SITE=/var/www/example.com
DEST=$HOME/backups
STAMP=$(date +%F)

mkdir -p "$DEST"
cd "$SITE"
wp db export - | gzip > "$DEST/db-$STAMP.sql.gz"
tar -czf "$DEST/files-$STAMP.tar.gz" --exclude=wp-content/cache wp-content wp-config.php .htaccess
rclone copy "$DEST" offsite:example-com-backups
find "$DEST" -type f -mtime +30 -delete

The script exports the database, archives the files without the cache folder, copies both off-site with rclone (set up beforehand with a remote named offsite), and deletes local copies older than 30 days. Adjust the paths if wp-config.php sits one level above the WordPress folder, which some hosts do. Schedule the script with cron, for example every night at 02:30 server time:

bash
30 2 * * * /home/deploy/bin/backup-wp.sh >> /home/deploy/backup.log 2>&1

Our cron expression generator builds and explains other schedules. The local copies are a convenience; the off-site copy is the backup that counts.

How do you test that a backup actually restores?

Restore it somewhere that is not the live site: a staging subdomain or a local copy with its own database. Keep the staging site's own wp-config.php, so the import goes into the staging database and never the live one. Then, from the staging site's folder:

bash
tar -xzf files-2026-10-30.tar.gz wp-content
gunzip < db-2026-10-30.sql.gz | wp db import -
wp search-replace 'https://example.com' 'https://staging.example.com' --skip-columns=guid

The first line extracts only wp-content from the archive. The last line points the restored content at the staging address. The staging wp-config.php must use the same table prefix as the live site, or WordPress will not find the imported tables.

Then check: the homepage loads, images appear, you can log in, a form submits, and the most recent content is there. Note how long the whole restore took. That is your real recovery time, and the person who will do it under pressure should have done it once in calm conditions.

Test a restore when you first set backups up, and every quarter after that.

What mistakes make backups useless?

  • Copies stored only on the same server. If the server fails or the account is compromised, they go with it.
  • Database only. A restore without uploads is a site with no images.
  • Failing silently. Storage fills up, an access token expires, and the plugin quietly stops uploading. Turn on failure emails and look at the backup log every month.
  • Too short a history. Seven days of copies of a site that was infected three weeks ago.
  • Nobody knows how to restore. Write down where backups live, who has access, and the steps. Keep that note somewhere other than the website.
  • Restoring the hack. After a compromise, restore from before the infection, then close the hole it came through. WordPress keeps getting hacked covers that process.

For backups across all platforms, not only WordPress, see website backups: what good looks like. For where backups fit in the rest of a WordPress setup, see WordPress for business websites.

Was this guide useful?

Questions

Frequently asked.

Are my host's backups enough?

They are a good first layer and the fastest way to roll back. They are not enough alone, because they usually sit with the same company, and sometimes in the same account, as the site. If the account is suspended, hacked or closed, the backups can go with it. Keep a second copy in storage you control.

Do backups slow down the site?

A full backup uses server resources while it runs, which can slow a site on small shared hosting. Schedule it for the quietest hour, and prefer incremental backups, which copy only changed files after the first run. Services that pull backups from outside the server have the least impact.

How long should I keep WordPress backups?

At least 30 days of daily copies for most company sites, and 90 days for stores and membership sites. Problems such as a hack or a deleted page are often noticed weeks later, and a short history may contain only bad copies. Keep a monthly copy for a year if storage allows.

Sohail Hussain

Founder, MSH Technologies

Sohail has designed and built websites, web apps and AI products for over 12 years, for clients from Singapore-based industrial groups to early-stage SaaS startups. He writes about what actually worked.

Keep reading

Related guides.

All posts

Your next move

Like what you see? Tell us about it.

A process that takes too long, a website that undersells you, or an idea ready to take shape. Tell us where you are and we will suggest a useful next step.

India · Working with clients worldwide

Sohail, Founder, replies within 1 working day (Mon–Sat, IST). Free and no obligation.