How to back up n8n in Docker (2026)
To back up n8n in Docker you cannot just dump the database — you also need the app's data volumes and its config. Dockstash dumps its PostgreSQL database consistently, captures the 2 volumes of on-disk data, and snapshots docker-compose.yml plus .env in one encrypted run.
What n8n stores
| Compose services | n8n, postgres |
|---|---|
| Databases detected | postgres |
| Data volumes | n8n_data (/home/node/.n8n), db_data (/var/lib/postgresql/data) |
| Config paths | docker-compose.yml, .env |
The backup plan
- Dump the PostgreSQL database. Run pg_dumpall -U "$POSTGRES_USER" inside the db container to capture all workflows, credentials, and execution history in one consistent snapshot.
- Capture the n8n data volume. Restic the /home/node/.n8n volume, which holds the encryption key and local files. Without the encryption key the restored credentials cannot be decrypted.
- Capture compose and .env config. Restic docker-compose.yml and .env — the N8N_ENCRYPTION_KEY and database settings must match on restore or stored credentials are unreadable.
Restoring n8n
The N8N_ENCRYPTION_KEY (in .env or the .n8n data dir) is critical: restore it exactly, or every stored credential becomes undecryptable even with a perfect database restore.
Back up n8n in one click All guides
Last updated: July 2026
Related database guides
Frequently asked questions
Why is the n8n encryption key so important to back up?
n8n encrypts stored credentials with N8N_ENCRYPTION_KEY. If you restore the Postgres database but lose the key, none of your workflow credentials can be decrypted. Back up the key and the database together.
Where does n8n store workflows?
In PostgreSQL (or SQLite for small setups). Dockstash runs pg_dumpall for a consistent snapshot of workflows, credentials metadata, and execution history.
Do I need the .n8n data volume too?
Yes — it holds the encryption key and any local binary data. Capture it alongside the database dump for a complete restore.