Automated Backup of Instance Workflows to GitHub - n8n Workflow

Use this robust n8n workflow to automatically backup all your n8n workflows to a specified GitHub repository. Ensure data safety and version control for your n8n automation projects.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

• n8n administrators requiring robust version control for their automation.
• Developers needing offsite, scheduled backups of their n8n workflows.
• Users looking for advanced examples of using the n8n node for instance management.
• Teams wanting to ensure their custom n8n templates are securely stored and tracked.

Overview

Maintaining reliable backups and version control for your automations is crucial. This advanced n8n workflow solves the problem of manual backup by systematically retrieving every single n8n workflow from your instance and storing it in a dedicated GitHub repository. Before pushing, the n8n automation compares the current workflow JSON structure with the existing file in GitHub. This ensures that only new or modified n8n workflows trigger a commit, keeping your repository clean and history meaningful. The entire process leverages the internal Execute Workflow n8n node to manage memory efficiently, allowing it to scale across hundreds of n8n templates without issues. This scheduled n8n trigger ensures your backups run automatically every two hours.

How it Works

The overall flow of this highly efficient n8n workflow is divided into two parts: the main loop and the subworkflow processing step.


  1. Initiation: The n8n trigger starts the process either via the Schedule Trigger (every 2 hours) or manually.

  2. Workflow Retrieval: The central n8n n8n node connects to the API to retrieve a comprehensive list of all published and unpublished n8n workflows present on the instance.

  3. Batch Processing: The Loop Over Items node (Split In Batches) iterates through the list of retrieved n8n workflow IDs.

  4. Self-Execution: The Execute Workflow n8n node calls the current workflow itself (acting as a subworkflow handler) for each individual workflow ID, mitigating memory strain.

  5. Subworkflow Execution: The Execute Workflow Trigger initiates the backup logic for a single n8n workflow item. The workflow retrieves crucial GitHub configuration details from the Globals node.

  6. GitHub Check: A GitHub n8n node attempts to retrieve the backup file, named by the workflow's ID, from the configured repository. If the file is too large to be retrieved directly, an If node and an HTTP Request n8n node fetch the full content.

  7. Difference Check: The custom isDiffOrNew n8n node compares the fetched GitHub backup content (after Base64 decoding) with the current version of the n8n workflow. It orders the JSON keys to ensure accurate comparison, determining if the status is 'same', 'different', or 'new'.

  8. Commit Action: A Switch n8n node routes the flow. If the status is 'different', the Edit existing file GitHub n8n node is executed. If the status is 'new', the Create new file GitHub n8n node is executed. If 'same', the process skips the GitHub action, conserving API calls. This completes the backup of one n8n workflow template.

Installation Guide


  1. Import the n8n Workflow: Copy the provided JSON data and import it directly into your n8n instance via the Workflow section's 'New' -> 'Import from JSON' option.

  2. Configure Credentials: Set up two mandatory credentials:

n8n API: Used by the n8n node to access the list of workflows on your instance. This typically requires an API key.
GitHub API: Used by the GitHub n8n node to read and write files to your repository. Ensure this token has repo scope permissions.

  1. Customize Globals: Open the Globals n8n node (a Set node) and update the following configuration values with your GitHub details:

repo.owner: Your GitHub username.
repo.name: The name of your backup repository (e.g., n8n-backups).
* repo.path: The folder path within the repository where backups should be stored (e.g., workflows/).

  1. Activation: Ensure the workflow is active. The Schedule Trigger will handle the automatic backup, making this an excellent recurring n8n template.

Node Details

Schedule Trigger / Manual Trigger (n8n trigger): Initiates the entire n8n workflow process. Provides flexibility for scheduled (every 2 hours) or manual execution.
n8n (n8n node): Core node used to list all workflows on the running n8n instance. Essential for gathering all available n8n templates.
Execute Workflow (n8n node): Executes the current workflow in a loop for each item, acting as a subworkflow handler to prevent memory overload when managing many n8n workflows.
Execute Workflow Trigger (n8n trigger): Serves as the entry point for the subworkflow, receiving the data for a single n8n workflow item.
Globals (Set node): Defines global configuration variables like GitHub repository owner, name, and path. Requires mandatory user configuration.
GitHub (n8n node - Get file data): Attempts to fetch the existing backup file for comparison.
If (If file too large): Flow control n8n node that checks if the GitHub API returned only a download URL instead of the file content, routing to an HTTP call if necessary.
Code (isDiffOrNew n8n node): Contains custom JavaScript logic to decode Base64 content, sort JSON keys to normalize the data, and compare the old and current n8n workflow versions, setting the crucial github_status variable.
Switch (Check Status n8n node): Directs the flow based on whether the n8n workflow is 'same', 'different', or 'new'.
GitHub (n8n node - Create new file / Edit existing file): Performs the final write operations to GitHub, either creating a new file or updating an existing backup file with the latest n8n workflow JSON.

Related n8n Workflows

Free

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

Freelance consultant from Brazil, specializing in automations and data analysis. I work with select clients, addressing their toughest projects. For business inquiries, email me at [email protected] or message me on Telegram for a faster response.

Featured*