On this page
- What does the 3-2-1 rule mean for a WordPress site?
- Which parts of WordPress actually need backing up?
- How do you make a manual backup with WP-CLI and tar?
- How do you automate it with a script and cron?
- How do you get a copy off the server?
- How do you restore a backup?
- Why should you test restores, and how often?
- What about backup plugins?
- Questions
What does the 3-2-1 rule mean for a WordPress site?
It means three copies of your data, on two different kinds of storage, with at least one kept somewhere else. For a site on a VPS that usually works out as: the live site itself, a recent archive on the same server for quick rollbacks, and an encrypted copy on a machine or storage service in another location. The local archive covers mistakes like a bad plugin update; the remote copy covers the loss of the whole server, a compromised account or a billing lapse.
A server-level snapshot is helpful but is not a replacement, because it sits with the same host. Our optional daily backups add-on (about +20% of the plan price, for example $1.44 on A1-2) gives you that server-level layer, and you restore from it through a support ticket. The steps below add the application-level copies you control yourself.
Which parts of WordPress actually need backing up?
Only two pieces are unique to your site: the database and the files you added or changed. Core files can be downloaded again at any time.
- Database: posts, pages, comments, users, settings and plugin data.
- wp-content: uploads, themes and plugins, including any custom code.
- wp-config.php: database credentials, salts and constants.
- Server config: the Nginx server block, PHP-FPM tweaks and your crontab, which take time to rebuild from memory.
Leave out cache folders such as wp-content/cache and plugin backup folders, which can be large and are rebuilt automatically.
How do you make a manual backup with WP-CLI and tar?
Export the database with WP-CLI, then archive the site directory and the server config with tar. Run it once by hand before you automate it.
sudo mkdir -p /var/backups/wp
cd /var/www/example.net
STAMP=$(date +%F)
sudo -u www-data wp db export - --single-transaction | gzip | sudo tee /var/backups/wp/db-$STAMP.sql.gz > /dev/null
sudo tar --exclude='wp-content/cache' -czf /var/backups/wp/files-$STAMP.tar.gz \
-C /var/www example.net
sudo tar -czf /var/backups/wp/conf-$STAMP.tar.gz /etc/nginx /etc/php* 2>/dev/null
ls -lh /var/backups/wpThe --single-transaction flag gives a consistent dump of InnoDB tables without locking the site. Lock the folder down with sudo chmod 700 /var/backups/wp, because the database dump holds password hashes and email addresses.
How do you automate it with a script and cron?
Put the commands into a script, add local retention, and call it from root's crontab every night.
sudo tee /usr/local/sbin/wp-backup.sh > /dev/null <<'EOF'
#!/bin/bash
set -euo pipefail
SITE=/var/www/example.net
DEST=/var/backups/wp
STAMP=$(date +%F-%H%M)
mkdir -p "$DEST"
sudo -u www-data wp --path="$SITE" db export - --single-transaction | gzip > "$DEST/db-$STAMP.sql.gz"
tar --exclude='wp-content/cache' -czf "$DEST/files-$STAMP.tar.gz" -C /var/www example.net
find "$DEST" -type f -mtime +7 -delete
EOF
sudo chmod 700 /usr/local/sbin/wp-backup.sh
sudo /usr/local/sbin/wp-backup.sh
echo '30 3 * * * root /usr/local/sbin/wp-backup.sh' | sudo tee /etc/cron.d/wp-backupSeven days of local archives is a reasonable start on a small disk; check usage with du -sh /var/backups/wp and adjust. On Rocky and Alma, replace www-data with nginx. The cron jobs guide explains the schedule fields.
How do you get a copy off the server?
Push the archives to a second location you control: another VPS, a home server, or any storage that rclone or restic supports. Two common routes:
rsync over SSH to a second machine
rsync -az --delete /var/backups/wp/ backup@203.0.113.50:/srv/backups/example.net/Use a dedicated SSH key for this account and restrict it on the receiving side. The rsync guide covers flags and key setup.
restic for encrypted, deduplicated history
sudo apt install -y restic # Ubuntu, Debian
sudo dnf install -y restic # Rocky, Alma (EPEL)
export RESTIC_REPOSITORY=sftp:backup@203.0.113.50:/srv/restic/example.net
export RESTIC_PASSWORD_FILE=/root/.restic-pass
restic init
restic backup /var/backups/wp /var/www/example.net/wp-config.php
restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prunerestic encrypts everything before it leaves the server, so the remote side never sees your data in clear text. Keep the repository password in a password manager as well; without it the backup cannot be opened. The daily backups tutorial shows restic in more depth alongside the add-on.
How do you restore a backup?
Unpack the files, import the database, and fix ownership. This works the same on the original server or a fresh one.
cd /var/www
sudo tar -xzf /var/backups/wp/files-2026-12-01-0330.tar.gz
sudo chown -R www-data:www-data /var/www/example.net
gunzip -c /var/backups/wp/db-2026-12-01-0330.sql.gz | sudo -u www-data wp --path=/var/www/example.net db import -
sudo -u www-data wp --path=/var/www/example.net cache flush
curl -I https://example.netIf the restore lands on a new domain or a staging address, rewrite URLs with wp search-replace 'https://example.net' 'https://staging.example.net' --all-tables. On a new server, create the database and user first as in the LEMP install guide.
Why should you test restores, and how often?
A backup you have never restored is a guess. Once a month, restore the newest off-server copy to a test location and click through the site. A small second instance or a local virtual machine both work well for this.
- Check that the latest post and the latest upload are present.
- Sign in as an admin and open a few plugin settings pages.
- Compare row counts:
wp db query "SELECT COUNT(*) FROM wp_posts;"on both copies. - Note how long the whole restore took, so you know your real recovery time.
Write the steps down while you do them. In a real incident you will be stressed, and a short checklist saves time.
What about backup plugins?
Plugins that back up to remote storage are fine as an extra layer, but they run inside WordPress and fail with it. If PHP is broken or the site is compromised, the plugin may not run or may itself be the problem. Server-side scripts like the one above run independently of WordPress, and the daily backups add-on runs independently of the operating system. Combining a server-side script, an off-server copy and the add-on gives you three independent paths back.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about Back up WordPress (3-2-1 rule)
How often should a WordPress site be backed up?
Daily suits most blogs and business sites. Shops and busy forums benefit from database dumps every few hours, since orders and posts change constantly.
Does the daily backups add-on replace my own backups?
No. It protects the whole server and you restore it by support ticket, but it lives with the same host. Keep your own off-server copy as well to meet the 3-2-1 rule.
How much does the backups add-on cost?
It adds about 20% to the monthly plan price. For example, it is $2.88 on A2-4. You choose it on the Deploy page.
Can I back up while the site is live?
Yes. wp db export with --single-transaction makes a consistent InnoDB dump without stopping the site, and tar can archive files while they are served.
Should backups be encrypted?
Any copy that leaves the server should be. restic encrypts by default; for plain archives use gpg --symmetric before upload.
More in Websites, CMS and shops
- WordPress on Nginx, PHP-FPM, MariaDB
- Fix common WordPress errors
- WordPress caching with Redis
- WooCommerce shop setup
- Ghost publishing platform
- Moodle learning platform
- phpBB forum
- Flarum forum
- Discourse community forum
- MediaWiki on Nginx and MariaDB
- Magento Open Source with OpenSearch
- PrestaShop store on Nginx
- OpenCart shop on Nginx
- Matomo web analytics
- Static site with Nginx and rsync
- Joomla on Nginx and PHP-FPM
- Drupal with Composer and Drush
- Vanilla Forums open source