Skip to main content

WordPress and Database Pattern

WordPress recovery requires filesystem state plus matching database state.

warning

Never rely on files-only backups for WordPress. If the database and uploads are out of sync, restores can be inconsistent.

What to Back Up

DomainTypical pathNotes
WordPress files/var/www/html/include wp-content/ and configs you need
Uploadswp-content/uploads/often the largest dataset
Database dumpbackup folderdump first, then snapshot together

Example Job

wordpress-hybrid-backup.sh
STAMP="$(date +%F-%H%M)"
mysqldump -u wp_user -p wp_db | gzip > "/backup/db/wp-${STAMP}.sql.gz"

rsync -a --delete /var/www/html/ /backup/wp/files/current/

restic backup /backup/wp/files/current /backup/db --tag wordpress --tag daily --host wp-01
rclone sync /backup/wp/files/current remote-prod:backups/wp/files/current

When prompted, enter the database password securely.

Suggested Restore Pairing

When restoring, pick:

  • the snapshot that contains the database dump you want
  • the matching file state from the same snapshot
tip

Tag WordPress and database snapshots consistently so a restore can recover a matched pair.