Who is this workflow for? Automate the backup of your n8n workflows by selecting tagged workflows and securely storing their definitions in a GitLab repository. This workflow ensures your critical automation configurations are version-controlled and easily recoverable..

What does this workflow do?

  • Fetch Workflows: The workflow retrieves all workflow definitions from your n8n instance.
  • Filter by Tags: It selects workflows that have one or more specified tags, allowing for configurable backup criteria.
  • Generate Filenames: For each selected workflow, a backup filename is created by simplifying the workflow name to include only alphanumeric characters without spaces.
  • Note: This method works well as long as workflow names are reasonably formatted.
  • Determine Backup Necessity: The workflow checks each selected workflow to identify if it has been modified or is new.
  • Modified: Any change, including node repositioning, marks the workflow for backup.
  • New: Newly created or renamed workflows are also included.
  • Commit to GitLab: Necessary workflow definitions are committed as JSON files to the specified GitLab repository. Each commit includes a generated, date-stamped message for easy reference.

Setup

Credentials

  • GitLab Credentials: Create and assign GitLab credentials to all GitLab nodes within the workflow.
  • n8n Credentials: Create and assign n8n credentials to the n8n node.
  • Note: Tested with http://localhost:5678/api/v1, but compatible with any accessible n8n instance and API key.

Global Variables

Configure the following values in the “Globals” node:

  • gitlab_owner: Your GitLab account name.
  • gitlab_project: The name of your GitLab project.
  • gitlab_workflow_path: The subdirectory in the project where backup files will be saved and committed.
  • tags_to_match_for_backup: Comma-separated tags used to select workflows for backup.
  • Alert: The n8n node requires workflows to have all listed tags, not just any. To match multiple tags inclusively, consider duplicating the node for single-tag matches or iterating through multiple values and merging results.

Possible Enhancements

  • Configurable Branch: Allow users to set the branch name for GitLab nodes instead of defaulting to “main.”
  • Audit Generation: Incorporate an n8n node to create an audit log and store it in GitLab alongside the backups.
  • Release Management: Extend the workflow to create a GitLab release or tag whenever backup files are updated or created.

🤖 Why Use This Automation Workflow?

  • Automated Backups: Eliminates the manual process of exporting and saving workflow definitions.
  • Version Control: Leverages GitLab’s capabilities to track changes and maintain history.
  • Selective Backup: Focuses on workflows tagged for backup, ensuring only important workflows are stored.

👨‍💻 Who is This Workflow For?

This workflow is ideal for developers, automation engineers, and teams using n8n who want to ensure their workflow configurations are consistently backed up and version-controlled without manual intervention.

🎯 Use Cases

  1. Disaster Recovery: Quickly restore workflows from GitLab in case of accidental deletions or system failures.
  2. Change Tracking: Monitor modifications to workflows over time to understand how automation processes evolve.
  3. Collaboration: Share workflow configurations with team members through GitLab, facilitating collaborative development and reviews.

TL;DR

This n8n workflow automates the backup of tagged workflows to GitLab, ensuring your automation configurations are securely version-controlled and easily accessible. By selecting specific workflows based on tags and committing their definitions to a GitLab repository, you can maintain robust backup practices with minimal effort.

Integrations

This workflow integrates seamlessly with tools like Zulip, Zammad, Google Sheets, Notion, Code, Slack, Webhook, AI Models (OpenAI, Anthropic, Gemini, OpenRouter), HTTP Request, Redis, Jira Software, and Merge, enhancing its versatility and applicability across various platforms.

Help us find the best n8n templates

About

A curated directory of the best n8n templates for workflow automations.