n8n Backup Strategy: How to Keep Your Workflows Safe
🔐 Why You Need a Backup Strategy for n8n
Whether you’re running n8n for a hobby project or managing mission-critical automations, data loss = workflow loss.
“A single failed VPS reboot or
docker rm
could wipe your entire automation setup.”
In this guide, you’ll learn how to back up your self-hosted n8n instance properly, including:
- ✅ Workflows & credentials
- ✅ Environment variables
- ✅ PostgreSQL or SQLite data
- ✅ Docker volume tips
- ✅ Automation tools for daily backups
📦 What You Need to Back Up
The key components of your n8n setup:
Component | Description | Backup Method |
---|---|---|
Workflows & Data | Stored in DB (Postgres or SQLite) | DB Dump (pg_dump ) |
Credentials | Encrypted, stored in DB | DB Dump |
.env Config | Env variables used by n8n (e.g., API keys) | Copy .env file |
Binary Data | If using binary mode, media may be on disk | Backup /files folder |
Static Config | Docker Compose or systemd service config | Backup .yml /.service |
🗃️ Option 1: PostgreSQL Backup
If you’re using PostgreSQL (recommended for production):
pg_dump -U n8n -h localhost -Fc n8n > n8n_backup_$(date +%F).dump
- Replace n8n with your DB name & user.
- Automate it with cron or n8n itself.
- Store the backup on a mounted drive or cloud bucket.
Restore example:
pg_restore -U n8n -d n8n_restored n8n_backup_2025-06-07.dump
🗃️ Option 2: SQLite Backup (For Lightweight Setups)
If you use SQLite (default for local installs):
cp ~/.n8n/database.sqlite ~/.n8n/database_backup_$(date +%F).sqlite
Or use rsync:
rsync -a ~/.n8n/ /backups/n8n/
⚠️ Note: Avoid copying while n8n is running, or you risk corrupted DB snapshots.
📂 Don’t Forget: .env and Config Files
Your .env
file often contains:
- N8N_HOST
- N8N_ENCRYPTION_KEY
- DB credentials
- Webhook secrets
Example:
cp /home/ubuntu/n8n/.env /backups/n8n_env_backup.env
Also back up your docker-compose.yml, nginx.conf, and systemd service files if you’re running n8n as a service.
🧪 Automate Backups with Cron (Recommended)
Example daily backup script (/opt/n8n-backup.sh):
#!/bin/bash
pg_dump -U n8n -h localhost -Fc n8n > /backups/n8n_$(date +%F).dump
cp /home/ubuntu/n8n/.env /backups/n8n_env_$(date +%F).env
Then add to crontab:
crontab -e
0 3 * * * /opt/n8n-backup.sh >> /var/log/n8n-backup.log 2>&1
This runs every day at 3 AM.
☁️ Optional: Upload Backups to the Cloud
Use tools like:
- rclone to sync to Google Drive or S3
- [scp] to send to another server
- [n8n + WebDAV/FTP node] to automate it inside n8n itself
🧾 Summary Checklist
✅ Item | Description |
---|---|
📂 .env backup | Sensitive config |
🗃 DB dump | Workflows, credentials |
⚙️ Docker/YML/systemd | Setup scripts |
📁 Files directory | If binary data used |
🔁 Cron job | Daily auto-backup |
☁️ Remote storage | Offsite or cloud |
🚨 Restore Test: Do This Once!
Make sure you can restore from backup. Don’t wait until disaster strikes.
“A backup isn’t real until you’ve successfully restored from it.”
🧠 Final Thoughts
Self-hosting n8n gives you freedom and control, but that means you are the sysadmin. Backing up takes just a few minutes and can save you hours of panic.
If you’re not sure how to set up automated backups or recovery, I offer support and maintenance services.
👉 Contact me here to secure your n8n setup with peace of mind.