Keeping your workflows safe is critical when you rely on automation to drive tasks, monitor systems, or power AI agents. Whether you're self-hosting or running n8n on a cloud instance, losing critical workflows due to a crash, update glitch, or human error can be costly. That’s why it’s essential to regularly back up n8n workflows—and even better if you can do it automatically.
In this guide, you’ll learn exactly how to backup n8n workflows automatically using built-in tools and a few simple techniques. We’ll walk you through step-by-step methods for local and cloud setups, with practical tips you can implement right away.
Why Backing Up n8n Workflows Matters
Before diving into methods, let’s quickly break down why backing up n8n workflows is not just a good habit—it’s a must.
Data Integrity and Protection
Workflows often contain API credentials, complex conditions, triggers, and integrations. Losing these could take hours or days to rebuild.
Migration and Testing
Having a workflow backup allows you to easily move between environments like development ➝ production or test ➝ live.
Disaster Recovery
If your virtual machine crashes, a Docker container restarts without persistence, or your local database corrupts, a backup lets you recover without starting from scratch.
Method 1: Export Workflows Using n8n CLI (Manual or Scripted)
n8n provides a command-line tool that lets you export workflows into JSON files. This works well for automation via cron jobs or bash scripts.
Step-by-Step: Export Workflows
-
Access Your Instance
Make sure you have SSH access or terminal access to where n8n is installed or running via Docker. -
Use the Export Command
Run the following command:n8n export:workflow --all --output=/path/to/backup/folder
This saves all workflows in JSON format to your specified folder.
-
Automate with Cron (Linux)
Edit your crontab:crontab -e
Add a line like this to run it daily:
0 1 * * * n8n export:workflow --all --output=/backups/n8n_$(date +\%F)
Now every night at 1 AM, your workflows are exported and timestamped.
Pros
- Supports full automation
- Keeps human-readable JSONs for Git/versioning
Cons
- Requires CLI access
- Only exports workflows (not credentials or other settings)
Method 2: Use Git and API Backup for Full Workflow Versioning
For teams or advanced users, combining workflow exports with Git provides version control and history.
Use n8n’s REST API to Export Workflows
-
Authenticate using your API key or session cookie.
-
Use the
/workflow
endpoint to fetch and save all workflows:curl -H "Authorization: Bearer YOUR_API_KEY" http://localhost:5678/api/v1/workflows > export.json
-
Commit to Git:
git add export.json git commit -m "Daily workflow backup $(date)"
-
Automate this with a script + cron for nightly commits.
For storing your backups externally, try integrating this with a platform like GitHub or GitLab. Many users even use n8n itself as the automation trigger for pushing data to repositories after each update.
Method 3: Backup Entire n8n Instance with Docker Volumes
If you’ve installed n8n using Docker, the database and workflows are stored inside a volume. To back up everything—including settings, credentials, executions—you can mount your data directory and back it up directly.
Step-by-Step: Backup Docker Volumes
-
Locate your n8n volume or data directory. Depending on your setup, it could be:
/home/user/n8n/.n8n/
-
Use
tar
to compress the folder:tar -czvf n8n-backup-$(date +%F).tar.gz /home/user/n8n/.n8n/
-
Move or sync this backup file to a secure storage like:
- AWS S3
- Google Drive (via rclone)
- Local NAS
-
Automate with cron or a daily n8n "Execute Command" node.
You can even restore from this backup simply by unpacking the compressed folder into the .n8n
directory and restarting your container.
Method 4: Backup Workflows Automatically Inside n8n
You can build an internal backup workflow using n8n’s own tools. Here’s how.
Building a Backup Workflow
- Trigger: Use a Cron node to run daily or weekly.
- HTTP Request: Call the
/workflows
API endpoint. - Write to File: Use the “Write Binary File” node to save the JSON result.
- Optional: Use nodes to upload the file to Google Drive, Dropbox, or email it to yourself.
Here’s a basic flow:
Node | Function |
---|---|
Cron | Triggers daily at 2 AM |
HTTP Request | Fetches all workflows |
Set Filename | Generates a dynamic file name |
Write Binary File | Saves to backups/ folder |
Upload/Email | Sends it externally or stores it |
If you’re already using n8n to run agents, you can even extend this flow into version alerting or Git commits.
Backup Strategy Tips
- Use Multiple Locations: Store your workflow backups in more than one place.
- Include Metadata: Add version or timestamp data inside filenames.
- Test Restores: Periodically try to import workflows from backup to confirm integrity.
- Secure Sensitive Data: Exported workflows may include credentials—encrypt your backups or exclude sensitive nodes.
If you're using multiple integrations or self-hosting, self-hosted n8n setup workflows will benefit greatly from regular file system backups.
Bonus: Use Cloud Storage with rclone or API Nodes
Want to send your backups off-site? Combine the n8n backup workflow with:
- Google Drive Node
- Dropbox Node
- WebDAV or SFTP
- rclone or AWS CLI in Shell/Command node
A sample n8n cloud backup flow:
- Cron → Export workflow
- Set filename
- Compress JSON →
.zip
- Upload to Drive or Dropbox
Pair this with an external trigger if you want weekly reports or failure alerts.
Pro tip: Sign up for n8n Cloud or upgrade your self-hosted setup for built-in execution logs, credential encryption, and auto-scaling—a big help as your workflow library grows.
FAQ
How can I restore n8n workflows from a backup?
You can import backup files (JSON) directly into n8n using the Import button inside the workflow editor or by using the CLI:
n8n import:workflow --input=/path/to/backup.json
Does exporting n8n workflows include credentials?
No, exporting workflows does not back up credentials. You'll need to back up the .n8n
directory or database to preserve those.
Can I use GitHub to version my n8n workflows?
Absolutely. Export workflows to JSON, commit them into GitHub, and use branches/tags for version control.
How do I backup n8n when running on cloud platforms like DigitalOcean?
If you're using n8n on DigitalOcean, you can back up the droplet itself, use volume snapshots, or deploy a workflow to extract workflows and push them to secure cloud storage regularly.
What’s the best method to backup workflows in Dockerized n8n?
Use volume mounting and compress the .n8n
directory daily. This ensures you’re capturing the database file that stores all your workflows, credentials, and data.
Automating the backup of your n8n workflows ensures peace of mind and business continuity. Whether you're using CLI tools, API pipelines, or internal workflows, backing up can be as simple or robust as you need it to be. Pick the method that suits you—and automate it today.