Quick overview
This workflow backs up all non-archived n8n workflows to a GitHub repository as JSON files, using a deterministic semantic SHA in each filename to detect new, updated, renamed, and deleted workflows and keep the repository in sync.
How it works
- Runs when you manually execute the workflow and loads the GitHub backup configuration (repo owner/name, visibility, commit messages, and filename separator).
- Retrieves all workflows from the n8n API, filters out archived workflows, and stops if there is nothing to back up.
- Creates a deterministic SHA-256 for each workflow based on its nodes, connections, and settings, and sanitizes the workflow name for use in the backup filename.
- Calls the GitHub REST API to verify whether the target repository exists and routes errors for connectivity, authentication, permissions, rate limits, and unexpected responses.
- If the repository is missing, creates it and uploads one JSON backup per workflow to the repository root using the
<id><separator><sha><separator><name>.json naming scheme.
- If the repository exists, lists repo files, compares them to current n8n workflows to identify new, changed, renamed, and deleted workflows, then creates replacement files before deleting outdated ones and removes backups for workflows deleted from n8n.
Setup
- Create an n8n API credential/connection with access to list workflows on your n8n instance.
- Add a GitHub OAuth2 credential with repo access (and permission to create repositories if you want auto-create) and ensure it can access the configured
repo_owner account or organization.
- Update the configuration values for
repo_owner, repo_name, and repo_private (and optionally commit messages and separator_character) to match your GitHub setup.
- If you want automated backups, replace the manual trigger with a schedule trigger and adjust the workflow execution timeout in settings if you have many workflows.