Automated Version Control and Backup for Workflows using GitHub - n8n Workflow

Use this advanced n8n workflow to automatically backup and version control your n8n workflows to GitHub. Features intelligent change detection, rename support, and optional Telegram reports.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Markdown-formatted text:
n8n administrators and developers needing reliable, scheduled backups of their n8n workflow infrastructure.
Teams requiring audited, granular change logs for n8n workflow modifications.
Users looking for advanced DevOps n8n templates for self-hosted or cloud n8n instances.
Anyone who needs to implement intelligent, version-controlled syncing of n8n data to external storage.

Overview

This solution addresses the critical requirement for automated, reliable version control and backup of your automation infrastructure. Relying solely on the n8n database for workflow storage carries risk; this advanced n8n workflow mitigates that by automatically syncing workflows to a GitHub repository.

The logic employs a custom Code n8n node to perform intelligent change detection, including handling workflow renames gracefully and executing stable JSON comparisons. This ensures that the GitHub repository receives clean, accurate commits only when actual modifications to the n8n workflow occur, providing a clean version history and functioning as an excellent auditing tool. This sophisticated n8n workflow dramatically improves the resilience and manageability of your n8n environment. For administrators, this n8n template is essential for maintaining control over deployed automations.

How it Works

This comprehensive n8n workflow operates on a scheduled interval to synchronize all active n8n workflows with a designated GitHub repository.


  1. Initiation: The Schedule Trigger n8n trigger starts the process periodically (default is hourly).

  2. Configuration Check: The workflow first retrieves essential parameters (Repo Owner, Name, Path) from the Configuration n8n node and uses the Assert GitHub config node to ensure all required credentials and settings are present, halting if configuration is incomplete.

  3. Data Collection & Preparation: The workflow concurrently fetches all current n8n workflows using the dedicated n8n node and retrieves the contents of all existing backup files from GitHub. The Encode N8N workflows and Extract workflow parameters nodes prepare the data by encoding the JSON content into Base64 for safe transit.

  4. Merge and Compare: The Merge node combines the current n8n workflow data with the historical GitHub data based on the workflow ID. The subsequent Decide changes n8n node runs custom logic to determine the necessary action (create, update, rename, or skip) by comparing the stable JSON structure of both versions.

  5. Action Routing: The Router n8n node directs each item to the required GitHub operation:

Skip: The workflow terminates early for this item.
Create: A new file is committed to GitHub.
Update: The existing file content is modified and committed.
Rename: This requires two GitHub calls: first, the old file is deleted; second, the new file is created with the updated name, ensuring a traceable history.

  1. Reporting: All processed items converge to the reporting path. The Build summary arrays n8n node compiles lists of created, updated, and renamed items. If changes occurred (or if the verbose setting in the Configuration n8n node is enabled), the Render summary n8n node formats a detailed MarkdownV2 report, which is then dispatched via Telegram.

Installation Guide

Markdown-formatted text:


  1. Import: Copy the provided n8n workflow JSON and import it into your n8n instance.

  2. Credentials: Set up the following credentials within your n8n environment:

GitHub API: Required for file operations (create, update, delete).
n8n API: Required for fetching the list of your active n8n templates.
Telegram API (Optional): Required only if you wish to receive execution reports.

  1. Configure: Open the green Configuration n8n node (a Set node) and provide the following details:

repo.owner: Your GitHub account username.
repo.name: The name of the repository where backups will be stored.
repo.path: The folder path within the repository (e.g., workflows/).
* report.tg.chatID (Optional): Your Telegram chat ID for notifications (set to 0 to disable reports).

  1. Connect Nodes: Link the newly created credentials to the respective GitHub, n8n, and Telegram n8n node configurations.

  2. Activate: Save and activate this core n8n workflow.

Node Details

Markdown-formatted text:
Schedule Trigger (n8n trigger): Initiates the entire n8n workflow at set intervals (default: hourly).
n8n Node (Get all workflows): Uses the n8n API to retrieve a list of all current n8n workflow definitions from the running instance. This is the source data for the backup.
GitHub Node (List files, Get files, Update file content): Multiple instances of this key n8n node handle communication with the GitHub API. It lists existing files, downloads their content for comparison, and performs the necessary create, update, or delete commits.
Code Node (Decide changes): This is the intelligence engine of the n8n workflow. It combines data from n8n and GitHub, uses Base64 decoding, and executes a key utility function (sortKeysDeep) to ensure stable JSON comparison, accurately detecting content changes regardless of formatting variation. It sets the operation type (rename, update, etc.).
Router (Switch Node): A core logic n8n node responsible for routing each individual n8n workflow item to the correct GitHub action path based on the operation determined by the Decide changes node.
Merge Node: Used extensively to maintain context flow, ensuring that metadata (like the operation type) from the previous steps remains available when merging the results of the GitHub commit operations back together before proceeding to the reporting stage.


  • Code Node (Render summary): Prepares a final, escaped MarkdownV2-formatted report detailing which n8n workflow items were processed, skipped, or renamed, ready for the Telegram n8n node.

Related n8n Workflows

Free

Nodes: 13 Nodes
Updated: December 26 2025
View all
Created by

I’m a generalist engineer who thrives on messy systems, undocumented protocols, and problems no one wants to touch Over the past 6 years, I’ve built infrastructure for managing hardware, reverse-engineered flaky devices, automated workflows end to end, and connected product logic to business reality Use my link to book an initial consultation

Featured*