Automatic Workflow & Credentials Backup to GitHub with Change Detection
Last edited 10 days ago
This n8n workflow template uses community nodes and is only compatible with the self-hosted version of n8n.
Title: n8n Credentials and Workflows Backup on Change Detection
Purpose: Never lose track of your n8n changes again! This workflow smartly backs up all your workflows and credentials, automatically detects any changes using hash comparison, and pushes updates to GitHub—but only when something has actually changed. Set your own interval and stop cluttering your repo with redundant commits.
Trigger:
- Schedule Trigger: Executes the entire process at a user-defined interval. No need to worry about traceability or managing countless backups, as the workflow only commits changes when a difference is detected.
Workflow Backup Process:
-
Set Workflow Path: Defines the local backup file path for workflows.
-
Get Old Workflow Hash: Executes a helper workflow to retrieve the previous hash.
-
Execute Workflow Backup: Runs
n8n export:workflow
to export all workflows to the defined file path. -
Get New Workflow Hash: Executes a helper workflow to generate the new hash from the exported file.
-
Compare Hashes (If Workflow Updated): Checks if the new hash differs from the old one.
-
If Updated:
- Read Workflow Data → Extract Text → Push to GitHub: Reads, extracts, and commits the updated workflow JSON to GitHub under a timestamped filename.
Credential Backup Process:
-
Set Credential Path: Defines the local backup file path for credentials.
-
Get Old Credential Hash: Executes a helper workflow to retrieve the previous hash.
-
Execute Credential Backup: Runs
n8n export:credentials
to export all credentials. -
Get New Credential Hash: Executes a helper workflow to generate the new hash from the exported file.
-
Compare Hashes (If Credential Updated): Checks for changes.
-
If Updated:
- Read Credential Data → Extract Text → Push to GitHub: Commits the new credentials JSON to GitHub if changes are found.
Hash Generator (Helper Flow): Used in both workflow and credential backup paths:
- Read File → Extract Text → Hash Data
- Outputs SHA-256 hash used for comparison
GitHub Integration:
- Commits are created with ISO timestamp in the filename and message.
- Repository:
https://github.com/your-github-name/n8n-onchange-bachup
- File paths:
backups/WorkFlow Backup -timestamp-.json
andbackups/Credential Backup -timestamp-.json
Change Detection Logic:
- Only commits files when hash changes are detected (i.e., actual content change).
- Avoids unnecessary GitHub commits and storage use.
Error Handling:
- GitHub nodes are set to continue workflow execution on error, avoiding full process interruption.
You may also like
New to n8n?
Need help building new n8n workflows? Process automation for you or your company will save you time and money, and it's completely free!