Automated Gitea Backup for Development Assets - n8n Workflow

Secure your automation logic by automatically backing up all your configured n8n workflow assets to a private Gitea repository. This n8n workflow ensures version control.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

DevOps Engineers managing mission-critical n8n instances and seeking reliable version control.
n8n Developers requiring scheduled, granular backup for every n8n workflow change.


  • Teams needing automated redundancy for their core n8n templates and production automation.

Overview

This robust n8n workflow solves the critical operational challenge of securing automation assets through workflow backup and version control. By leveraging the internal n8n API, this automation periodically extracts every single n8n workflow, checks if changes have occurred since the last run, and commits the updated JSON definition to a dedicated Gitea repository. This provides developers and administrators with a secure, off-site record of all active n8n templates. The design uses conditional logic (If n8n node checks) and custom Base64 encoding via a Python Code n8n node to interact with the Git API seamlessly. This efficiency ensures that only changed n8n workflows trigger an update, optimizing API usage and maintaining a clean commit history for every n8n template.

How it Works


  1. Scheduled Execution: The process begins with the Schedule n8n trigger, initiating the backup process automatically every 45 minutes.

  2. Configuration Loading: The Globals n8n node loads environment variables defining the Gitea repository URL, owner, and name.

  3. Workflow Retrieval: A specialized n8n n8n node communicates with the local n8n API to fetch the JSON definition for all existing n8n workflows.

  4. Batch Processing: The ForEach n8n node iterates over the results, ensuring each n8n workflow is processed individually for backup.

  5. Gitea Existence Check: The GetGitea HTTP Request n8n node attempts to retrieve the corresponding file from Gitea. It is configured to handle 404 errors (file not found) gracefully.

  6. Conditional Routing: The Exist If n8n node checks the response. If the file is new, the n8n workflow proceeds to the creation path. If it exists, it proceeds to the update path.

  7. Data Encoding: Whether updating or creating, the workflow utilizes a Python Code n8n node (Base64Encode...) to convert the n8n workflow JSON into a Base64 string, as required by the Gitea API.

  8. Change Detection (Update Path): The Changed If n8n node compares the newly encoded content against the content retrieved from Gitea. If they differ, the n8n workflow is considered modified.

  9. Commit Action: If changed, the PutGitea HTTP Request n8n node updates the existing file. If new, the PostGitea HTTP Request n8n node creates the file, completing the backup of that specific n8n workflow.

Installation Guide


  1. Import the n8n workflow: Copy the provided JSON data and paste it into your n8n canvas to create this new n8n workflow.

  2. Configure Gitea API Credentials: In your n8n Credentials Manager, create a new HTTP Header Auth credential (e.g., named 'Gitea Token'). Set the Name to Authorization and the Value to Bearer YOURACCESSTOKEN. Ensure this token has repo read/write permissions in Gitea. Assign this credential to the GetGitea, PutGitea, and PostGitea n8n node components.

  3. Configure n8n API Credentials: Ensure the internal n8n n8n node is connected to a credential that allows it to retrieve workflow definitions from your local n8n instance.

  4. Set Global Variables: Open the Globals Set n8n node and update the values:

repo.url: Your Gitea instance URL.
repo.name: The target repository name (e.g., workflows).
* repo.owner: The repository owner's username (e.g., n8n).

  1. Activate: Test the n8n trigger and activate the n8n workflow to begin scheduled backups of all your n8n templates.

Node Details

Schedule Trigger: The primary n8n trigger, responsible for setting the backup frequency (currently every 45 minutes).
Globals (Set n8n node): Centralized location to define Gitea connection details used by subsequent HTTP Request n8n node operations.
n8n (n8n node): Connects to the host n8n API to retrieve JSON data for all available n8n workflow definitions.
ForEach (Split In Batches n8n node): Splits the incoming array of n8n workflows so that each is processed individually through the backup logic.
GetGitea (HTTP Request n8n node): Attempts to retrieve the existing backup file from Gitea, using onError: continueRegularOutput to detect if the n8n workflow is new.
Exist (If n8n node): Flow control logic that branches the n8n workflow execution based on whether the file exists in the repository or needs to be created.
Base64EncodeUpdate/Create (Code n8n node - Python): These custom n8n node scripts handle the crucial step of converting the JSON n8n workflow data into Base64 format for the Gitea API.
Changed (If n8n node): Performs a byte-level comparison to determine if the local n8n workflow has changed since the last backup.
PutGitea (HTTP Request n8n node): Executes the update command to commit changes to an existing n8n workflow file in the Gitea repository.
PostGitea (HTTP Request n8n node): Executes the creation command to upload a new n8n workflow file to the Gitea repository.

Related n8n Workflows

Free

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

Hi, I’m Llewellyn van der Merwe, also known as <<ewe>>yn, pioneering tools to automate freedom!

Featured*