Automated Workflow Backup to GitHub Repository - n8n Workflow

Use this robust n8n workflow template to schedule automatic, reliable backups of all your n8n workflow configurations directly to GitHub, ensuring version control and disaster recovery.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • n8n users running critical, complex automations who require reliable disaster recovery plans.

  • DevOps professionals needing version control and change management for their n8n solutions.

  • Teams looking to synchronize n8n workflow development across shared environments using standard Git practices.

  • Anyone seeking a standardized n8n template for system maintenance.

Overview

Ensuring the integrity and availability of your automation assets is paramount. This highly valuable n8n workflow solves the critical problem of manual or infrequent backups by automating the entire process. By utilizing a scheduled n8n trigger and leveraging the n8n API, the workflow exports all current n8n workflow definitions as a JSON file and pushes them to a designated GitHub repository every six hours (customizable). This provides immediate, version-controlled disaster recovery capability, allowing users to effortlessly rollback changes, track historical configurations, and gain peace of mind that their hard work—the underlying n8n template logic—is secure. This dedicated n8n node sequence is a vital addition to any self-hosted n8n environment.

How it Works

This automation initiates using the Schedule Trigger n8n trigger, configured to run every six hours.


  1. Trigger and Data Retrieval: The Schedule Trigger fires, which immediately calls the Get All Workflows n8n node. This HTTP Request node hits the n8n instance's REST API endpoint (/rest/workflows) to fetch a JSON array containing all active n8n workflow definitions. Authentication is handled via the X-N8N-API-KEY header.

  2. Data Preparation: The output JSON is passed to the Move Binary Data n8n node, which converts the JSON structure into a binary format suitable for file upload, ensuring the backup is handled correctly by GitHub.

  3. Attempting Update: The workflow first attempts to update the existing backup.json file in GitHub using the Edit a file n8n node. This node is configured with an important setting: onError: continueErrorOutput. This means if the file does not exist (resulting in a 404 error from GitHub), the workflow does not stop but passes the error data forward.

  4. Conditional Check (File Existence): The If file not exits? n8n node checks the output of the 'Edit' step. If the output contains the specific error message, "The resource you are requesting could not be found," it confirms the file is missing.

  5. Creating the File: If the check confirms the file does not exist, the workflow branches to the Create a file n8n node, which performs the initial commit of the backup.json file. If the file already existed and was successfully edited, the workflow terminates successfully after Step 3.

Installation Guide

To deploy and utilize this n8n template, follow these steps:


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

  2. GitHub Credentials: Configure the required GitHub credentials in the Edit a file and Create a file n8n node instances. This typically requires a Personal Access Token with repository write permissions.

  3. Configure GitHub Details: Update the owner, repository, and filePath parameters in both GitHub n8n node instances to match your desired backup repository.

  4. Configure API Endpoint: In the Get All Workflows HTTP Request n8n node:

- Update the URL to match your n8n instance URL (e.g., https://my.n8n.domain.com/rest/workflows?limit=9999).
- Replace in the X-N8N-API-KEY header with a valid API key from your n8n user settings.

  1. Set Schedule: Adjust the interval in the Schedule Trigger n8n trigger node if you require backups more or less frequently than the default 6 hours.

  2. Activate: Save and activate the n8n workflow. The first backup will run at the next scheduled interval.

Node Details

This n8n workflow relies on several core n8n node types to achieve reliable, scheduled version control:

Schedule Trigger (n8n trigger):
Function: Starts the entire n8n workflow automation flow at specified intervals.
Key Configuration: Set to trigger every 6 hours (hoursInterval: 6).

Get All Workflows (HTTP Request n8n node):
Function: Retrieves all workflow data from the running n8n instance via the internal REST API.
Key Configuration: Uses a customized URL (/rest/workflows?limit=9999) and requires authentication using the X-N8N-API-KEY header.

Move Binary Data (n8n node):
Function: Converts the JSON data containing all n8n workflow definitions into a binary file format, which is required for GitHub file operations.
Key Configuration: Mode set to jsonToBinary and fileName dynamically set to backup.

Edit a file (GitHub n8n node):
Function: Attempts to update the existing backup.json file in the GitHub repository.
Key Configuration: operation: edit, binaryData: true, and crucially, onError: continueErrorOutput to allow error handling if the file does not exist.

If file not exits? (If n8n node):
Function: Implements conditional logic. It checks if the preceding 'Edit file' n8n node failed because the resource (file) could not be found, indicating a first run or missing backup file.
Key Configuration: Checks if the error message equals "The resource you are requesting could not be found".

Create a file (GitHub n8n node):
* Function: Executes only if the conditional check confirms the file does not exist, creating the initial backup.json file in the repository.

Related n8n Workflows

Free

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

I'm a developer with 5 years of experience in Python and Node.js. Over the past year, I've been building workflows to streamline operations for my team. I have also developed RAG chatbots, AI agents, and WhatsApp automation. If you need any help with N8N workflows, let's connect over a call and solve it together!

Featured*