Automated Workflow Backup to GitLab with User Organization - n8n Workflow

Use this robust n8n workflow to automatically back up all your n8n workflows to a GitLab repository, organized by user creator for version control and disaster recovery. This efficient n8n automation ensures data safety.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

DevOps Engineers: Needing reliable version control and disaster recovery for their n8n environment.
Technical Teams: Managing a shared n8n instance and requiring organization based on workflow ownership.
n8n Admins: Seeking automated, scheduled backups using a structured n8n workflow template.
Automation Specialists: Who want to leverage the internal n8n node for self-monitoring.

Overview

Maintaining version control for complex automation flows is critical. This n8n workflow solves the problem of manual backup and disorganized storage by automatically retrieving all defined n8n workflows and committing them to a centralized GitLab repository. A key feature of this n8n automation is the dynamic assignment of workflows to user-specific folders (e.g., 'vrushti', 'poojan', 'general') based on names parsed from the workflow title. This ensures clean organization and easier auditing. This robust n8n workflow utilizes core logic nodes to handle file existence checks, ensuring that existing files are updated rather than throwing errors, resulting in highly reliable daily or weekly operations.

How it Works

This powerful n8n workflow can be initiated manually via the manual n8n trigger, or automatically via the weekly scheduled n8n trigger.


  1. Trigger & Fetch: The execution starts, and the dedicated n8n node connects back to the local n8n instance using its API credentials to fetch a list of all existing n8n templates and workflows.

  2. Metadata Preparation: A Set n8n node prepares global variables like the current date for use in pathing.

  3. Batch Processing: The Split In Batches n8n node processes each retrieved workflow individually.

  4. Formatting & User Assignment: A Set n8n node formats the workflow data into a clean JSON object and, crucially, determines the creatorName (e.g., 'ajay', 'vrushti') by checking keywords within the workflow's name. It then constructs the final GitLab filePath using this creator name for organization.

  5. GitLab Commit (Create Attempt): The GitLab n8n node attempts to create the new workflow file in the repository. The workflow uses a Wait n8n node to mitigate potential rate-limiting issues.

  6. Existence Check: An If n8n node checks if the creation attempt failed due to an existence error (a common response when trying to create an existing file via the GitLab API).

  7. Update or Continue: If the file exists, a subsequent GitLab n8n node performs an 'Edit' operation, updating the existing backup file with the latest n8n workflow data and committing the changes. If the file was successfully created, the flow continues.

  8. Completion & Notification: After all n8n workflow items have been processed, a final Email Send n8n node sends a notification confirming the successful completion of the entire automated backup process.

Installation Guide


  1. Import: Import this n8n workflow JSON into your n8n instance.

  2. n8n API Credentials: Update the 'Fetch N8N Workflows' n8n node with credentials that allow API access to your own n8n instance (usually an API key). This is essential for the n8n workflow to retrieve its own data.

  3. GitLab Credentials: Set up or select your GitLab API credentials for the 'Create to GitLab Repository' and 'Update Backup Summary' GitLab n8n nodes. Ensure the token has sufficient permissions (read/write access to repository files).

  4. Configuration: Specify the target GitLab owner, repository (n8n-backup), and branch (e.g., main).

  5. User Logic Adjustment: Review the Format Workflow for GitLab Set n8n node logic. Adjust the user names (vrushti, poojan, pragnesh, ajay) in the expression to match the workflow creators in your organization.

  6. SMTP Setup: Configure the 'Send email' n8n node with your SMTP credentials and the desired recipient and sender emails.

  7. Activate: Set the n8n workflow to 'Active' to enable the scheduled n8n trigger.

Node Details

Manual Backup Trigger / Scheduled Weekly Backup (n8n trigger): Initiates the execution flow. The scheduled n8n trigger runs weekly on Fridays.
Fetch N8N Workflows (n8n node): Essential for retrieving data about the current installation. It uses the n8n API to query all existing n8n templates and workflows.
Prepare Backup Metadata (Set n8n node): Generates variables for dynamic file pathing, ensuring backups are organized by year and month.
Process Each Workflow (Split In Batches n8n node): Ensures that each n8n workflow is processed individually, facilitating granular control and logging for the subsequent GitLab operations.
Format Workflow for GitLab (Set n8n node): Performs complex data transformation, extracting the full workflow JSON and applying custom JavaScript logic to infer the workflow creator's username for folder organization.
Rate Limit Control (Wait n8n node): Introduces a 2-second delay between file operations to respect GitLab API rate limits, increasing the reliability of the overall n8n workflow.
Create to GitLab Repository (GitLab n8n node): Attempts the initial commit of the workflow file. It is configured to continue on fail, allowing the subsequent check to determine the cause.
Check Backup Status (If n8n node): Determines if the file creation failed because the n8n workflow file already exists in the repository.
Update Backup Summary (GitLab n8n node): If the file exists, this node updates the content via the 'Edit file' operation, ensuring the latest n8n workflow version is saved.
Send email (Email Send n8n node): Provides final confirmation that the automated n8n backup process is complete.

Related n8n Workflows

Free

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

The AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.

Featured*