Backup Workflows to Git Repository on Gitea
This workflow implements regular backups of automated processes to a designated Gitea Git repository, ensuring secure storage and version management of the workflow. It is automatically triggered every 45 minutes to detect changes in the workflow, updating the repository only when there are content changes to avoid duplicate submissions. The built-in Base64 encoding enhances the security of data transmission, while flexible conditional checks ensure the accuracy of newly added or updated files, making it suitable for users who require private deployment and efficient management of automated processes.

Workflow Name
Backup Workflows to Git Repository on Gitea
Key Features and Highlights
This workflow automates the backup of all n8n workflows to a specified Gitea Git repository. It supports scheduled triggers and automatically detects workflow changes, updating repository files only when content modifications occur to avoid redundant commits. The workflow incorporates built-in Base64 encoding to ensure secure data transmission and storage, and uses flexible conditional logic to distinguish between creating new files and updating existing ones.
Core Problems Addressed
- Automates backup of n8n workflows to prevent data loss
- Synchronizes workflow changes promptly to the Git repository, ensuring version control
- Minimizes redundant commits, optimizing Git repository update efficiency
- Integrates with the Gitea API for seamless connection to private Git repositories
Use Cases
- Enterprises or individuals managing automation processes with n8n who need regular backups of workflow scripts to prevent accidental loss
- Version control and collaborative development of workflows via Git repositories
- Users requiring private Git server deployment (e.g., Gitea) and synchronization of automation workflow data to private repositories
- Operations teams aiming for scheduled automatic backup and versioning of n8n workflows
Main Process Steps
- Scheduled Trigger: Automatically initiates the backup process every 45 minutes.
- Set Global Variables: Configure Gitea repository URL, repository name, and owner information.
- Fetch All n8n Workflows: Use n8n API to retrieve all current workflow data.
- Iterate Over Workflows: Process each workflow individually in batch mode.
- Check if Workflow File Exists in Gitea Repository: Use GetGitea node combined with existence check logic.
- Branch Processing Based on File Existence:
- If file exists, prepare update content (SetDataUpdateNode + Base64EncodeUpdate) and call PUT API to update the file.
- If file does not exist, prepare creation content (SetDataCreateNode + Base64EncodeCreate) and call POST API to create the file.
- Change Detection: Compare the latest content with repository content; commit only if changes are detected.
- Commit Changes to Gitea: Use PutGitea or PostGitea nodes to update or create files via the Gitea API.
- Automatically Loop Through All Workflow Files: Complete backup synchronization for all workflows.
Involved Systems and Services
- n8n: Serves as the data source to obtain all automation workflow definitions.
- Gitea: Private Git service hosting all workflow backup files.
- HTTP Request Nodes: Invoke Gitea API to perform file operations.
- Python Code Nodes: Handle Base64 encoding of workflow JSON data.
- Scheduled Trigger: Enables automated periodic execution.
Target Users and Value
- n8n Automation Platform Users: Operations personnel and developers who need to ensure workflow security and version control.
- Enterprise Technical Teams: Those aiming to integrate automation workflows into standard code repository management systems.
- Private Git Service Users: Organizations requiring backups of automation workflows to internal Git servers for security and compliance.
- Automation Operations Engineers: Professionals building automated backup mechanisms to enhance operational efficiency and stability.
This workflow significantly simplifies the backup process for n8n workflows, ensuring secure storage and version tracking of automation processes. It is a vital tool for building an efficient and reliable automated operations environment. Simply configure the Gitea-related settings and activate the workflow to enjoy seamless automated backups.