
Mike Maiolo | Pontavia ConsultingKey takeaways n8n can export every workflow and credential with n8n export:workflow and n8n...
Key takeaways
- n8n can export every workflow and credential with
n8n export:workflowandn8n export:credentials.- Exported credentials stay encrypted, so a backup is useless without your
N8N_ENCRYPTION_KEY. Store the key separately.- A backup you have never restored is a guess. Import into a throwaway instance once to prove it works.
Your workflows live in n8n's database (SQLite by default). If the disk, container volume or VM is lost, everything goes with it: every workflow, every credential, every setting. Exporting to plain files gives you a copy you can store anywhere and put in version control.
Run these on the host where n8n runs. For Docker, prefix them with docker exec -u node <container>.
mkdir -p /backups/n8n/workflows /backups/n8n/credentials
n8n export:workflow --all --separate --output=/backups/n8n/workflows/
n8n export:credentials --all --separate --output=/backups/n8n/credentials/
--separate writes one JSON file per workflow or credential, which makes diffs and partial restores much easier. By default the credentials file keeps secrets encrypted. There is a --decrypted flag, but a decrypted export is a plain-text file full of passwords and API keys, so avoid it unless you have a very good reason.
Credentials are encrypted with the key in the N8N_ENCRYPTION_KEY environment variable (or, if you never set it, a key n8n generated and saved in its config file, usually ~/.n8n/config). To restore credentials on a new instance, it must use the same key. Put the key in your password manager, not next to the backup files.
n8n import:workflow --separate --input=/backups/n8n/workflows/
n8n import:credentials --separate --input=/backups/n8n/credentials/
Do this on a fresh instance first, with the same encryption key, and open a few workflows to confirm the credentials attach and a test run works.
#!/usr/bin/env bash
set -euo pipefail
DEST=/backups/n8n/$(date +%F)
mkdir -p "$DEST/workflows" "$DEST/credentials"
n8n export:workflow --all --separate --output="$DEST/workflows/"
n8n export:credentials --all --separate --output="$DEST/credentials/"
# keep two weeks of dated folders
find /backups/n8n -mindepth 1 -maxdepth 1 -type d -mtime +14 -exec rm -r {} +
Run it from cron, then copy /backups/n8n to another machine. A backup on the same disk as n8n is not much of a backup.
.env, reverse proxy config and any mounted files are separate.I write practical Proxmox, n8n and small business IT guides at pontaviaconsulting.com/guides.html.