Automated Daily Workflow Backups to GitHub - n8n Workflow

Use this robust n8n workflow to automatically backup and version control all your active n8n workflows to a GitHub repository, ensuring data safety and easy rollback.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • n8n instance administrators seeking robust disaster recovery solutions.

  • Developers needing version control and change tracking for their n8n templates.

  • Users running critical automations who require reliable backups of every n8n workflow configuration.

  • Anyone looking for a complete DevOps solution for their n8n environment.

Overview

Maintaining reliable backups of your automation logic is paramount. This professional n8n workflow solves the problem of manual backups by providing a complete, scheduled automation using a powerful n8n trigger. Every 24 hours, the n8n node sequence checks your entire n8n instance. It intelligently compares the current configuration of each n8n workflow against its last committed version in GitHub. Using custom comparison logic, it only commits changes if the workflow structure is truly 'different' or if it is a 'new' n8n template being backed up for the first time. This ensures efficient use of your GitHub repository and provides a complete audit trail for all changes made to your crucial n8n workflow configurations.

How it Works

This automation begins with a scheduled n8n trigger, initiating the daily backup process.


  1. Configuration & Retrieval: The process starts by setting repository configuration variables and then uses the 'Get Workflows' n8n node to retrieve metadata for all workflows running on the instance.

  2. Filtering: A 'Filter' n8n node ensures that only workflows updated within the last 24 hours are processed, minimizing API calls and processing time.

  3. Iteration: The 'Loop Over Items' node iterates through each recently updated n8n workflow.

  4. GitHub Check: For each workflow, a GitHub n8n node attempts to retrieve the existing backup file. If the file is too large or not found, additional logic handles the retrieval or error.

  5. Comparison Logic: The custom 'isDiffOrNew' Code n8n node performs a critical function: it deserializes and compares the existing backup JSON (if present) against the newly retrieved n8n workflow JSON, ensuring keys are sorted for accurate string comparison. It sets a status flag ('same', 'different', or 'new').

  6. Routing & Action: A 'Switch' n8n node directs the flow based on the comparison status:

If 'Same': The process iteration ends (no action required).
If 'New': The 'Create new file' GitHub n8n node uploads the new n8n workflow data.
* If 'Different': The 'Edit existing file' GitHub n8n node updates the existing file, documenting the change in the commit message.

  1. Completion: Upon finishing all iterations, a final optional Slack message (via a Slack n8n node) confirms that the entire set of n8n templates has been processed.

Installation Guide


  1. Import the n8n workflow: Copy the provided JSON data and paste it into your n8n instance using the 'New' -> 'Import from JSON' option.

  2. Configure Credentials: You will need two primary credentials:

GitHub API: Configure a GitHub credential (PAT) with repository write access and apply it to the 'Get a file', 'Create new file', and 'Edit existing file' GitHub n8n nodes.
n8n API: Configure an n8n credential pointing to your local n8n instance API to allow the 'Get Workflows' node to retrieve workflow definitions.
(Optional) Slack API: If you wish to enable notifications, configure the Slack credential on the 'Starting Message' and 'Completed Notification' n8n nodes.

  1. Set Configuration Variables: Open the 'Config' n8n node (a Set node) and populate the following values:

repoowner: Your GitHub username or organization name.
reponame: The name of the repository where backups will be stored (e.g., n8n-workflows).
sub_path: The directory path within the repository (e.g., folder).

  1. Set Schedule: Adjust the 'Schedule Trigger' n8n trigger frequency if daily backups are not desired.

  2. Activate: Save and activate the n8n workflow.

Node Details

Schedule Trigger: This is the primary n8n trigger, configured to run the backup process on a recurring schedule (defaulting to daily).
Get Workflows (n8n node): Retrieves a list of all active n8n templates (workflows) on the current n8n instance. This is essential for knowing what needs to be backed up.
Filter: Filters the list to only include n8n workflow items where the updatedAt timestamp is within the last 24 hours, optimizing processing for large instances.
Loop Over Items (Split In Batches): Allows the workflow to process each n8n workflow item sequentially, enabling individual GitHub operations.
Get a file (GitHub node): Attempts to fetch the existing backup file from GitHub, using the workflow name to form the file path. Crucially configured to 'continueRegularOutput' on errors (like 404 Not Found).
isDiffOrNew (Code node): A custom n8n node script that determines the sync status ('same', 'different', or 'new'). It decodes Base64 content from GitHub and compares the workflow JSON structures, ensuring reliable comparison by sorting object keys before stringifying.
Switch: Routes the flow based on the status set by the isDiffOrNew node.
Edit existing file (GitHub node): Executes when a change is detected. Commits the updated n8n workflow JSON, including the commit message identifying the change type (different).
Create new file (GitHub node): Executes when a new n8n workflow is detected. Creates the initial backup file.
Completed Notification (Slack node): (Disabled by default) Sends a summary notification after the entire execution, detailing how many n8n templates were processed.

Related n8n Workflows

Free

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

Analyst-Developer

Featured*