Why bother
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.
Export everything
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.
Keep the encryption key
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.
Restore
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.
A simple nightly script
#!/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.
What this does not cover
- Execution history. Past runs are not in these exports. Back up the database too if you need them.
- Environment variables and files. Your
.env, reverse proxy config and any mounted files are separate. - Community nodes. Reinstall these after a restore.
Related guides
- Get Alerted When an n8n Workflow Fails
- Follow Up on Unanswered Inquiries Automatically
- Appointment Reminders and No-Show Follow-Up
- All guides
Questions about your own setup? Send a message or book a free 15-minute call.