Skip to main content

Automated daily backup of n8n workflows to GitLab repositories

Workflow preview

Workflow preview
100%
Automated daily backup of n8n workflows to GitLab repositories preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

n8n Workflow: Sync Workflows with GitLab How It Works This workflow ensures that your self hosted n8n workflows are version controlled in a GitLab repository. It compares each current workflow from...

Best for

  • DevOps automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.set, n8n-nodes-base.noop, n8n-nodes-base.splitinbatches, n8n-nodes-base.gitlab, n8n-nodes-base.code, n8n-nodes-base.extractfromfile, n8n-nodes-base.switch, n8n-nodes-base.n8n

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Akhil Varma Gadiraju.

Original n8n.io source

1.1 Workflow description

Title
Automated daily backup of n8n workflows to GitLab repositories
Workflow name
Automated daily backup of n8n workflows to GitLab repositories

n8n Workflow: Sync Workflows with GitLab

How It Works

This workflow ensures that your self-hosted n8n workflows are version-controlled in a GitLab repository. It compares each current workflow from n8n with its stored counterpart in GitLab. If any differences are detected, the GitLab file is updated with the latest version.

Core Logic:

  1. Retrieve Workflows – Fetch all workflows from the n8n REST API.

  2. Compare with GitLab – For each workflow, fetch the corresponding file from GitLab and compare the JSON.

  3. Update if Changed – If differences exist, commit the updated workflow to GitLab using its API.


Setup

Before using the workflow, ensure the following:

Prerequisites:

  • n8n: Self-hosted instance with access to the /rest/workflows API.

  • GitLab: A repository where workflows will be stored, and a Personal Access Token (PAT) with api and write_repository permissions.

  • n8n Nodes Required:

    • HTTP Request (to call n8n and GitLab APIs)
    • Code or Function nodes (for diffing and formatting)
    • Looping (SplitInBatches or similar)

Configuration:

  • Set environment variables or workflow credentials for:
    • GITLAB_TOKEN
    • GITLAB_REPO
    • GITLAB_BRANCH (e.g., main)
    • GITLAB_FILE_PATH_PREFIX (e.g., n8n-workflows/)

How to Use

  1. Import the Workflow into your n8n instance.

  2. Configure GitLab API Credentials:

    • Set the GitLab PAT as a header in the HTTP

Request node:
Private-Token: {{ $env.GITLAB_TOKEN }}

  1. Map Workflows to GitLab Paths:

    • Use the workflow name or ID to create the file path. Example:
      n8n-workflows/workflow-name.json
  2. Trigger the Workflow:

    • Can be manually triggered, or scheduled to run at intervals (e.g., daily).
  3. Review Commits in GitLab:

    • Each updated workflow will be committed with a message like:
      "Update workflow: Sample Workflow"

Disclaimer

  • This workflow does not handle merge conflicts or manual edits made directly in GitLab. Always ensure proper coordination if multiple sources are modifying workflows.
  • Only structural changes are tracked. Non-functional metadata (like timestamps or IDs) may trigger false positives unless filtered.
  • Use at your own risk. Test in a safe environment before applying to production workflows.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Globals

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.2

Block 2 - Result

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 3 - Current workflow

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 4 - Loop Over Workflows

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 5 - Get file

Type / Role
n8n-nodes-base.gitlab - gitlab
Config choices
Version 1

Block 6 - File status

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 7 - Status error

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.2

Block 8 - End Loop

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 9 - Create file

Type / Role
n8n-nodes-base.gitlab - gitlab
Config choices
Version 1

Block 10 - Extract From File

Type / Role
n8n-nodes-base.extractFromFile - extractFromFile
Config choices
Version 1

Block 11 - Switch

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3

Block 12 - New file version

Type / Role
n8n-nodes-base.gitlab - gitlab
Config choices
Version 1

Block 13 - Error output to normal output

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 14 - Status diff

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.2

Block 15 - Status same

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.2

Block 16 - Retrieve all workflows

Type / Role
n8n-nodes-base.n8n - n8n
Config choices
Version 1

Block 17 - Save each version in a different field

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.2

Block 18 - Schedule Trigger

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

Block 19 - GitLab

Type / Role
n8n-nodes-base.gitlab - gitlab
Config choices
Version 1

3. Summary Table

Workflow Automated daily backup of n8n workflows to GitLab repositories
Complexity advanced
Nodes 19
Categories DevOps
Author Akhil Varma Gadiraju
Published 14 May 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/4035/4035.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Automated daily backup of n8n workflows to GitLab repositories do?

n8n Workflow: Sync Workflows with GitLab How It Works This workflow ensures that your self hosted n8n workflows are version controlled in a GitLab repository. It compares each current workflow from...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your DevOps use case.