What This Workflow Does
This workflow automatically backs up all the workflows from an n8n instance to a GitHub repository every day. It solves the problem of manual backup tasks that take time and risk losing data. The workflow compares each workflow’s current version with the saved version in GitHub to avoid unnecessary uploads, organizing backups by year and month folders.
The result is a quick, automatic backup process that saves time and prevents errors.
Who Should Use This Workflow
Anyone managing many n8n workflows and needing regular safe backups should use this. It is useful for n8n instance admins who want to avoid manual backup errors and keep their workflows organized by date. It works well even if there are over 1,000 workflows, thanks to batch processing and recursive subflows.
Tools and Services Used
- n8n: Automation platform to run the workflow.
- GitHub API: Stores workflow JSON files in a repository.
- Slack API (optional): Sends notifications about backup start, success, or failures.
- HTTP Request node: Handles large file fetches in GitHub.
Inputs, Processing, and Outputs
Inputs
- n8n workflows fetched via admin API credentials.
- GitHub repository path and access token.
- Slack webhook URL and channel ID (optional).
Processing Steps
- The workflow triggers daily via Schedule Trigger.
- Sends Slack message to notify start.
- Fetches all workflows from n8n using the n8n API node.
- Splits the workflows into batches using SplitInBatches for manageable processing.
- Calls a subworkflow for each workflow to process individually.
- Checks for the existing backup file in GitHub using a path based on creation date.
- If file is missing or empty, uses HTTP Request node to fetch the file correctly.
- Compares workflow JSON content inside Code node to classify the file as same, new, or different.
- Creates or updates the backup file in GitHub accordingly with commit messages summarizing the action.
- Sends Slack messages for completion or failure of backups.
Outputs
- Organized backups in GitHub folder structure by year and month.
- Slack notifications about process status.
- Logs of backup success and failure recorded in n8n.
Beginner step-by-step: How to Use This Workflow in n8n
Step 1: Import the Workflow
- Download the workflow file using the Download button on this page.
- Open the n8n editor and choose “Import from File”.
- Select and import the downloaded workflow file.
Step 2: Add Credentials
- Configure your n8n admin API credentials inside the n8n API node.
- Set GitHub API credentials with proper repo access for backup nodes.
- Optionally, set Slack webhook credentials in Slack nodes for notifications.
Step 3: Update Parameters
- Check and update folder paths, Slack channel IDs, or other settings as needed.
- If needed, adjust batch size in SplitInBatches node for your server.
Step 4: Test the Workflow
- Run the workflow once manually to verify correct operation.
- Look for Slack notification and GitHub commits confirming backups.
Step 5: Activate Backup Schedule
- Enable the Schedule Trigger node to start automatic daily backups.
- Monitor n8n execution logs and Slack messages for backup health.
Edge Cases and Failure Handling
If GitHub file access fails due to permissions, errors show in logs and Slack notifies with failed workflow IDs.
Batch size too large may cause out-of-memory errors; reduce batch size in SplitInBatches.
Scheduling mistakes cause missed backups if Schedule Trigger node is not enabled.
GitHub API rate limits might delay uploads; plan API usage or implement retries.
Customization Ideas
- Change backup frequency by adjusting Schedule Trigger node settings.
- Customize GitHub folder structure by editing the code in Set node that builds subpaths.
- Modify Slack notification channels by changing the channel IDs in Slack nodes.
- Add error handling in Execute Workflow node to stop or continue on failures.
- Enhance version comparison logic by updating the Code node to add extra metadata to commits.
Summary
✓ Automates daily backups of all n8n workflows into GitHub.
✓ Prevents manual errors and saves over 15 minutes per backup.
✓ Organizes backup files into year/month folders for easy access.
✓ Sends Slack notifications to inform about backup start, success, and failures.
✓ Handles large workflow counts by batch processing and recursive calls.
