How to back up Directus in Docker (2026)
A complete Directus backup has three parts: dump its PostgreSQL and MySQL databases 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 Directus stores
| Compose services | directus, postgres, redis |
|---|---|
| Databases detected | postgres, mysql |
| Data volumes | directus_uploads (/directus/uploads), db_data (/var/lib/postgresql/data) |
| Config paths | docker-compose.yml, .env, extensions |
The backup plan
- Dump the database. Run pg_dumpall (or mysqldump --single-transaction) to capture collections, fields, roles, permissions, and file metadata consistently.
- Capture the uploads directory. Restic the /directus/uploads volume. Directus stores file metadata in the database but the binary assets live on disk (or configured object storage).
- Capture compose, .env, and extensions. Restic docker-compose.yml, .env (KEY and SECRET), and the extensions directory so custom endpoints and hooks are restored.
Restoring Directus
File metadata in the database must match the assets in /directus/uploads — restore both. Preserve the KEY and SECRET from .env or session tokens and cached data become invalid.
Back up Directus in one click All guides
Last updated: July 2026
Related database guides
Frequently asked questions
Where does Directus store uploaded files?
File metadata lives in the database, but the actual assets are stored in /directus/uploads (or configured object storage). Back up both so file references resolve after restore.
What database backends does Directus support?
PostgreSQL and MySQL/MariaDB are the common choices. Dockstash detects the backend and dumps it consistently for that engine.
Why back up the KEY and SECRET env values?
They sign and encrypt tokens. Restoring the database without matching KEY/SECRET invalidates sessions and any encrypted values.