Quick tutorial on moving n8n data between containers. You’ll learn to export workflows and credentials, copy them out of Docker, and reimport on a fresh instance.
What you’ll learn
- Set up docker-compose with encryption key and volumes
- Export workflows with
n8n export:workflow --all - Export credentials (encrypted or decrypted)
- Use
docker cpto move files in/out of containers - Reimport everything on a new instance
Docker Compose setup
Create your .env file with the encryption key:
N8N_ENCRYPTION_KEY=your-generated-key-here
Your docker-compose.yml binds a volume for two-way data access between the container and host:
services:
n8n:
image: n8nio/n8n
environment:
- N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
- GENERIC_TIMEZONE=UTC
volumes:
- ./data:/home/node/.n8n
Start with:
docker compose up -d
Exporting workflows and credentials
Export all workflows:
docker compose exec n8n n8n export:workflow --all --output=/home/node/.n8n/backups/
Export credentials (encrypted):
docker compose exec n8n n8n export:credentials --all --output=/home/node/.n8n/backups/
Export credentials (decrypted) for moving to a different instance:
docker compose exec n8n n8n export:credentials --all --decrypted --output=/home/node/.n8n/backups/
Copying data out of the container
Use docker cp to copy the backups folder to your host:
docker cp n8n:/home/node/.n8n/backups ./backups
Reimporting on a fresh instance
Copy files back into the container:
docker cp ./backups n8n:/home/node/.n8n/backups
Import credentials first:
docker compose exec n8n n8n import:credentials --input=/home/node/.n8n/backups/
Then import workflows:
docker compose exec n8n n8n import:workflow --input=/home/node/.n8n/backups/
Production note
For production deployments, consider using a tool like Kamal for proper secret management and deployment orchestration. Docker alone lacks the tooling to make credential handling safe at scale.
Related Posts
n8n Encryption Key: Complete Guide to N8N_ENCRYPTION_KEY, Credential Security & Recovery
A practical guide to n8n credential security. Learn N8N_ENCRYPTION_KEY fundamentals, setup for Docker/Kubernetes/systemd, best practices, recovery drills, and a real case study.
How to Backup and Restore n8n Docker Volumes (With Cron Examples) – Step‑by‑Step Guide
Practical guide to back up and restore n8n Docker volumes (/home/node/.n8n) with copy‑paste scripts and cron jobs. Avoid data loss by saving the encryption key.
GitOps Backups for n8n: 30‑Minute Schedule + One‑Click Restore
Set up two n8n flows: a Git backup every 30 minutes and a manual restore. Copy‑paste CLI, node configs, and security best practices for safe rollbacks.
n8n Docker Setup: Encryption Key, Volumes & Backup Guide
Complete guide to setting up N8N_ENCRYPTION_KEY in Docker, troubleshooting the _FILE variant issue, configuring persistent volumes, and backing up workflows and credentials safely.