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...
🔌 Nodes & Integrations Used (3)
📖 Implementation & Setup Guide
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
- **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 }}`
3. **Map Workflows to GitLab Paths**: - Use the workflow name or ID to create the file path. Example: `n8n-workflows/workflow-name.json`
4. **Trigger the Workflow**: - Can be manually triggered, or scheduled to run at intervals (e.g., daily). 5. **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.
---
⚡ How to import this workflow into n8n:
- Click the Direct Download JSON button above to save
Automated_daily_backup_of_n8n_workflows_to_GitLab_repositories.json. - Log in to your n8n Cloud or self-hosted n8n instance.
- In your workflow canvas, click the menu in top-right and select Import from File (or paste the JSON directly).
- Configure your credentials (e.g. API keys, database URLs) in the corresponding node settings.
- Click Execute Workflow to test and switch to Active!
Related Docs, PDF & OCR Workflows
View All in Docs, PDF & OCR →Add articles to a Notion list by accessing a Discord slash comma
This workflow allows you to add articles to a Notion reading list by accessing a Discord slash command. Prerequisites - A Notion account and [credentials](),...
Adobe PDF Services API Automation
Production-ready n8n automation template for Adobe PDF Services API Automation built by AhiXLight. Seamlessly connects HTTP Request, Execute Workflow Trigger, Dropbox with 20 configured nodes.
Adobe PDF Services API Workflow
Production-ready n8n automation template for Adobe PDF Services API Workflow built by AhiXLight. Seamlessly connects HTTP Request, Execute Workflow Trigger, Dropbox with 20 configured nodes.
AI Brand Voice Content Generator
Production-ready n8n automation template for AI Brand Voice Content Generator built by AhiXLight. Seamlessly connects Lm Chat Open Ai, Information Extractor, HTTP Request with 27 configured nodes.