Skip to main content

Excluding Folders

Exclusions keep backups smaller and restores cleaner. The goal is to exclude churn (caches, temporary files, nested archives) while never excluding unique user data (uploads) or critical configuration.

Quick Summary
  • Exclude rebuildable data (caches, tmp).
  • Exclude nested backups (avoid "backup inside backup").
  • Quote patterns so your shell does not expand them.
  • Validate exclusions with a restore drill.

What is usually safe to exclude

Common WordPress candidates:

  • wp-content/cache/
  • wp-content/*/cache/
  • Backup plugin output folders (if you store those elsewhere): wp-content/updraft/
  • Logs: *.log (optional; keep if you need forensic history)
  • Nested archives: *.zip, *.tar*, *.zst, *.gz

What you should almost never exclude

  • wp-content/uploads/ (this is user content)
  • wp-content/plugins/ (unless you can reinstall and accept drift)
  • wp-content/themes/
  • wp-config.php (handle as a secret, but do not lose it)

Excludes with tar

tar-backup-with-excludes.sh
sudo tar -C /var/www/html \
--exclude='wp-content/cache' \
--exclude='wp-content/*/cache' \
--exclude='wp-content/updraft' \
--exclude='*.log' \
--exclude='*.zip' \
--exclude='*.tar*' \
--exclude='*.zst' \
-czf "/backups/wp-files-$(date +%F).tar.gz" \
.

Excludes with rsync

rsync-backup-with-excludes.sh
sudo rsync -a \
--exclude 'wp-content/cache/' \
--exclude 'wp-content/*/cache/' \
--exclude 'wp-content/updraft/' \
--exclude '*.log' \
/var/www/html/ \
/backups/files-current/

Excludes with zip

zip-backup-with-excludes.sh
zip -r /backups/site.zip /var/www/html \
-x '*/cache/*' \
-x '*/updraft/*' \
-x '*.log' \
-x '*.zip'

Excludes with rclone

rclone-copy-with-excludes.sh
rclone copy /backups remote:wp-backups/site-a \
--exclude '*.tmp' \
--exclude '*.partial'

Verification

After you take a backup with excludes:

  1. list contents
  2. restore into staging
  3. confirm key WordPress paths exist
verify-excluded-backup-by-restore-drill.sh
sudo rm -rf /tmp/restore-test
sudo mkdir -p /tmp/restore-test

sudo tar -xzf /backups/wp-files-2026-03-01.tar.gz -C /tmp/restore-test
sudo find /tmp/restore-test -maxdepth 3 -type d -name wp-content -print
sudo find /tmp/restore-test -maxdepth 4 -type d -name uploads -print

Next steps

  • Backup logging and verification: opt/docker-data/apps/docusaurus/site/docs/server/linux-server/10-backup-disaster-recovery/backup-logging-and-verification.mdx.