How to back up WordPress in Docker (2026)

A complete WordPress backup has three parts: dump its MySQL database the correct way, capture the 2 data volumes that hold files on disk, and save the compose file and .env. Dockstash detects all three automatically, dumps the database from the running container, and restics everything off-site.

What it stores

What WordPress stores

Compose serviceswordpress, mysql
Databases detectedmysql
Data volumeswp_data (/var/www/html), db_data (/var/lib/mysql)
Config pathsdocker-compose.yml, .env, wp-content, uploads.ini
Step by step

The backup plan

  1. Dump the MySQL database. Run mysqldump --all-databases --single-transaction --routines --triggers inside the db container so the WordPress schema and content are captured at one consistent point without locking writers.
  2. Capture the wp-content volume. Restic the wp_data volume (themes, plugins, and the uploads directory). This is where all media and customizations live outside the database.
  3. Capture compose and .env config. Restic docker-compose.yml, .env (DB credentials, salts), and any php/uploads.ini overrides so the stack rebuilds identically.

Restoring WordPress

Restore the mysqldump into a staging database first, then swap it in; restore wp-content alongside so media URLs resolve. Keep the .env salts consistent or existing sessions and encrypted values break.

Back up WordPress in one click All guides

Last updated: July 2026

Frequently asked questions

Is backing up the MySQL database enough for WordPress?

No. WordPress stores posts and settings in MySQL but keeps themes, plugins, and all uploaded media in wp-content on disk. You need both the database dump and the wp-content volume to fully restore.

Why not just copy the MySQL data directory?

A live /var/lib/mysql copy is inconsistent and often will not restore. Dockstash runs mysqldump --single-transaction inside the container for a consistent, restorable dump.

Do I need to back up wp-config.php?

Yes — capture it via the project directory or .env. It holds the database credentials and authentication salts your restored site needs to match.