What This Workflow Does
This workflow saves copies of all n8n workflows automatically every 2 hours to a GitHub repository.
It solves the problem of losing workflows when they get accidentally changed or deleted.
The result is a backup of all workflows with version history on GitHub.
It helps prevent work loss and saves time by not needing to manually export workflows.
How It Works: Input, Process, Output
Inputs
- n8n API: Provides current workflows.
- GitHub API: Stores workflow JSON files.
Processing Steps
- Fetch all workflows from n8n with API.
- Split workflows one by one for checking.
- Try fetching matching workflow file from GitHub.
- If file is missing or large, handle accordingly.
- Merge n8n and GitHub data for comparison.
- Compare files to see if new, changed, or same.
- Skip update if no change to save resources.
- Create new file or update existing on GitHub if needed.
Outputs
- Updated GitHub repo with backups of all workflows.
- Version control history of workflow changes.
Who Should Use This Workflow
This is useful for users who manage many workflows in n8n.
Especially if workflows change frequently or multiple people edit them.
It helps anyone wanting automatic backups without manual exporting.
Also good for those needing version history and recovery options.
Tools and Services Used
- n8n: The automation tool running the workflow.
- GitHub API: For storing workflow files and managing versions.
- GitHub Personal Access Token: To authenticate with GitHub.
Beginner Step-by-Step: How to Use This Workflow in n8n
Step 1: Import Workflow
- Download the workflow using the Download button on this page.
- Open the n8n editor (like self-host n8n if self hosting).
- Use the “Import from File” option to load the downloaded workflow.
Step 2: Configure Credentials and Settings
- Add your n8n API credentials in the appropriate node.
- Add your GitHub Personal Access Token with repo permissions.
- In the “Globals” node, update
repo.owner,repo.name, andrepo.pathto your GitHub repository details.
Step 3: Test the Workflow
- Run the manual trigger named On clicking ‘execute’ to backup workflows immediately.
- Check your GitHub repo to confirm workflows are saved.
Step 4: Activate for Production
- Activate the Schedule Trigger to run every 2 hours automatically.
- Monitor run logs in n8n to confirm backups happen without errors.
Customization Ideas
- Change how often backups run by editing the Schedule Trigger interval.
- Organize backups by updating the folder path (
repo.path) in the “Globals” node. - Add workflow metadata fields in the isDiffOrNew code node if extra info should be saved.
- Improve large file handling with retry logic or alerts.
- Include notifications after manual backups using email or Slack nodes.
Troubleshooting Common Issues
- GitHub file fetch fails with ‘file not found’:
Verify repository owner, name, and folder path in the “Globals” node are correct. - Existing file updates not committing:
Check JSON comparison in isDiffOrNew code node to see if changes are detected. - Large workflow files not updating:
Ensure fallback HTTP request for large files triggers correctly and GitHub token has correct scopes.
Pre-Production Checklist
- Test GitHub credentials with simple read and write.
- Check n8n API access by fetching workflow list manually.
- Confirm manual trigger backs up workflows to GitHub.
- Verify scheduled trigger runs every 2 hours.
- Create manual backups of important workflows before activating automation.
Deployment Guide
Enable the Schedule Trigger node to start automatic backups every 2 hours.
Use manual trigger for testing or on-demand backups.
Watch workflow logs for errors and confirm GitHub files update.
Add notifications if needed to alert on backup success or failure.
Summary of Benefits
✓ Automatically saves all n8n workflows to GitHub every 2 hours.
✓ Protects against accidental workflow loss or overwrite.
✓ Keeps clear version history with minimal unnecessary commits.
✓ Saves user time by cutting manual exports.
✓ Easy to customize frequency, folders, and metadata.
