Daily Automated Workflow Backup to GitLab - n8n Workflow

Secure your critical automations with this daily n8n workflow backup. Automatically sync active n8n templates to GitLab, using an n8n node for internal API access, complete with failure Slack alerts.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Sysadmins managing self-hosted n8n instances.

  • DevOps teams requiring source control and versioning for automation scripts.

  • Users looking for reliable, automated n8n workflow backup solutions.

  • Automation specialists who rely heavily on the robustness of their n8n node implementations.

Overview

The provided n8n workflow is a critical operational tool for maintaining data integrity and version control for your automation assets. Self-hosting n8n often necessitates a robust backup strategy; this specific n8n workflow solves that challenge by using the internal n8n node to export every active n8n template as a JSON file. It leverages GitLab for reliable storage, allowing the user to track changes to every n8n workflow via standard Git versioning. The workflow is highly efficient because it compares existing files before attempting to update or create, minimizing unnecessary API calls. It also includes crucial error handling, sending detailed failure reports via Slack if any file update or creation fails in GitLab. This ensures your n8n infrastructure is secure and auditable, giving you peace of mind regarding your critical n8n workflow definitions.

How it Works

The automation begins with the Daily Trigger n8n trigger, configured to run every day at 12:00. This highly useful n8n trigger initiates the entire backup process.


  1. Configuration and Preparation: The Configuration n8n node first sets essential variables (GitLab project owner, name, and branch). Simultaneously, the 'List All Files - GitLab' n8n node retrieves the names of all files currently stored in the repository. These names are aggregated by the 'List of Names' n8n node for quick lookup.

  2. Data Retrieval and Filtering: The 'Get All Workflows' n8n node uses the internal n8n API credential to fetch the JSON definition of every single n8n workflow instance. The 'Discard Archived Workflows' n8n node then filters this list, ensuring that only active n8n templates proceed to the backup stage.

  3. Iteration and Transformation: The 'Process Each File' Split In Batches n8n node iterates over each active n8n workflow. Inside this loop, the JSON is cleaned by the 'Remove Unwanted Fields' n8n node to remove extraneous metadata (like IDs and timestamps) before being converted into a binary file format by the 'Convert to File' n8n node.

  4. Conditional Write to GitLab: The 'If File Exists' n8n node checks if the current workflow name is present in the list aggregated earlier.

If True, the 'Update File - GitLab' n8n node runs. If this update fails, the 'Update File - Failed' Slack n8n node sends an immediate alert.
If False, the 'Create New File - GitLab' n8n node runs. If this creation fails, the 'New File - Failed' Slack n8n node sends a specific failure notification.

  1. Completion: Once all n8n templates have been processed by the Split In Batches n8n node, the 'Send Message to Channel' Slack n8n node executes, confirming the successful completion of the entire n8n workflow backup operation.

Installation Guide


  1. Import: Copy the provided JSON data and import it directly into your n8n instance as a new n8n workflow.

  2. GitLab Setup: Create the necessary project repository in GitLab. Create a GitLab API Access Token with the necessary scopes (like api and writerepository). Configure the GitLab n8n credential using this token.

  3. n8n Internal Setup: Create a new n8n API key specifically for this n8n workflow. Use this key to set up the 'n8n Internal' credential, ensuring the Base URL points to your n8n instance API endpoint (e.g., https://your-n8n-domain.com/api/v1).

  4. Slack Setup: Create a Slack App and acquire a Bot Token. Configure the Slack n8n credential using the Access Token and Signing Secret. Ensure the bot is added to the target backup notification channel.

  5. Configuration Node: Edit the 'Configuration' n8n node and replace the placeholder values (projectowner, project_name, branch) with your specific GitLab details.

  6. Activate: Enable the n8n workflow. The n8n trigger will run daily at the scheduled time.

Node Details


  • Daily Trigger (Schedule Trigger): Acts as the starting n8n trigger, initiating the backup process daily at 12:00.

  • Configuration (Set n8n node): Defines configuration variables (projectowner, projectname, branch) used by subsequent GitLab n8n node operations. Essential for customizing the target repository.

  • Get All Workflows (n8n n8n node): Utilizes the internal n8n API credential to retrieve the raw JSON data for every existing n8n workflow on the instance.

  • Discard Archived Workflows (Filter n8n node): Ensures data quality by filtering the input and only processing live n8n templates (where isArchived is false).

  • Process Each File (Split In Batches n8n node): Breaks down the list of active n8n templates into individual items, allowing the subsequent n8n node chain to handle each file sequentially.

  • Remove Unwanted Fields (Code n8n node): Cleans the JSON structure of the n8n workflow by removing fields like id, createdAt, and updatedAt, which are specific to the instance and not needed in a clean backup n8n template.

  • Convert to File (Convert To File n8n node): Takes the cleaned JSON data and converts it into a binary file object, required for upload via the GitLab n8n node.

  • If File Exists (If n8n node): The core control flow n8n node. It compares the current workflow name against the list of files already in GitLab to decide between updating or creating a new file.

  • Update File - GitLab/Create New File - GitLab (GitLab n8n node): Handles the actual interaction with the repository, either updating an existing n8n workflow file or pushing a new one. Both are configured with onError: continueErrorOutput to enable failure reporting.

  • Update File - Failed/New File - Failed (Slack n8n node): Dedicated error reporting n8n nodes that notify the configured Slack channel if any GitLab operation fails, providing the error message and the name of the affected n8n workflow.

Related n8n Workflows

Free

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

AI Developer & Automation Consultant

Featured*