Backup wp-content Only
In many WordPress restores and migrations, the only unique files are under wp-content/ (themes, plugins, uploads). WordPress core can be reinstalled from upstream. This approach can reduce backup size and restore time, but it still requires a database backup.
Quick Summary
- Back up
wp-content/+ database. - Also capture
wp-config.php(treat as a secret). - Reinstall WordPress core during restore.
- Validate by restoring into staging.
When this is a good idea
- You have a reproducible WordPress core (same major/minor version).
- You want faster transfers for a large site.
- You are comfortable rebuilding server config (nginx/php-fpm) from docs.
When this is a bad idea
- You need a full forensic snapshot (include everything).
- The server has custom code outside
wp-content/. - You are not sure what is unique on disk.
Create the wp-content archive
backup-wp-content-tar-zst.sh
sudo mkdir -p /backups
sudo tar -C /var/www/html \
--exclude='wp-content/cache' \
--exclude='wp-content/*/cache' \
-cf - wp-content \
| zstd -3 -T0 -o "/backups/wp-content-$(date +%F).tar.zst"
Create the database dump
backup-db-for-wp-content-only.sh
mysqldump --single-transaction --quick --routines --events --triggers \
--column-statistics=0 wordpress \
| zstd -3 -T0 -o "/backups/wp-db-$(date +%F).sql.zst"
Capture wp-config.php (as a secret)
backup-wp-config-as-secret.sh
sudo install -m 700 -d /backups/secrets
sudo install -m 600 /var/www/html/wp-config.php "/backups/secrets/wp-config-$(date +%F).php"
Restore workflow (high-level)
- Install WordPress core (same version).
- Restore
wp-content/. - Restore database.
- Restore or recreate
wp-config.php. - Fix permissions.
warning
Restoring into /var/www/html can overwrite production files. Use a staging directory first.
restore-wp-content-to-staging.sh
sudo rm -rf /tmp/restore-test
sudo mkdir -p /tmp/restore-test
sudo tar --use-compress-program=zstd -xf /backups/wp-content-2026-03-01.tar.zst -C /tmp/restore-test
sudo find /tmp/restore-test -maxdepth 2 -type d -name uploads -print
Next steps
- Secrets handling:
opt/docker-data/apps/docusaurus/site/docs/server/linux-server/10-backup-disaster-recovery/backup-env--wpconfigphp.mdx.