Automate robust version control for your n8n instances. This n8n workflow uses an n8n trigger to fetch all active n8n templates and back them up securely to GitHub, ensuring data integrity and easy rollback.
Download this n8n workflow template and start using it instantly.
n8n administrators requiring consistent backup and versioning of their automation environment.
DevOps teams implementing Infrastructure-as-Code practices for n8n deployments.
Users managing critical, complex n8n workflows and needing reliable historical records.
Anyone looking for an efficient way to manage and deploy changes across multiple n8n instances.
Managing complex automation requires reliable version control. Without it, unintended changes to an n8n workflow can lead to difficult debugging and potential data loss. This automation solves the critical problem of workflow redundancy by leveraging a schedule n8n trigger to automatically synchronize all active n8n templates with a Git repository (GitHub).
This robust n8n workflow checks if the file exists, if the content has changed, and only commits updates if necessary, minimizing repository noise while ensuring that every iteration of your n8n workflow is captured securely.
The process begins with the Schedule Trigger, acting as the primary n8n trigger, initiating the backup process on a recurring interval.
Globals (Set), defines key variables, specifically the target GitHub repository name, owner, and the path where the n8n workflows should be stored.n8n node connects to the local n8n API to retrieve a list of all currently active n8n workflows (or n8n templates).Loop Over Items n8n node processes each retrieved n8n workflow individually.GitHub n8n node attempts to retrieve the existing file from the repository. By using continueOnFail: true, the workflow proceeds even if the file is not found (meaning it's a new workflow).If n8n node determines if the file retrieval failed (new workflow) or succeeded (existing workflow). Create new file and commit, pushing the entire n8n workflow JSON to GitHub.Code n8n node, which decodes the Base64 content received from GitHub back into a usable JSON string.If1 n8n node compares the current n8n workflow data (from the n8n API) with the content retrieved from GitHub. If they are different, a change is detected.Update file content and commit n8n node pushes the updated n8n workflow JSON, completing the backup for that specific item. If no changes are detected, the loop continues to the next n8n workflow.To deploy this automated n8n workflow, follow these steps:
GitHub and Create new file and commit and Update file content and commit) using a Personal Access Token (PAT) with repository write permissions.Globals (Set) n8n node and update the repo.owner, repo.name, and repo.path variables to match your desired backup repository details.Schedule Trigger n8n trigger is set to the desired frequency (e.g., every 5 minutes, every hour). The n8n workflow can then be activated. Schedule Trigger (n8n trigger): The starting point for the n8n workflow. Configured to run periodically (e.g., every minute) to check for updates.
Globals (Set n8n node): Central configuration node. Used to store GitHub repository details (owner, name, and the 'workflows/' file path prefix) for easy modification across the n8n workflow.
n8n (n8n node): Fetches all available n8n templates and workflows from the local n8n API endpoint using an API credential.
Loop Over Items (Split In Batches n8n node): Essential flow control n8n node that iterates through the list of retrieved n8n workflows, allowing individual processing for each file.
GitHub (n8n node - Get): Attempts to retrieve the content of the existing workflow file from GitHub. Configured to continue on failure, which signifies a new n8n workflow.
If (n8n node): Checks if the GitHub retrieval failed (meaning the n8n workflow is new and needs to be created).
Code (n8n node): Executes custom JavaScript to decode the Base64 content retrieved from GitHub, converting the file content into a readable string for comparison.
If1 (n8n node): Performs the crucial check: comparing the new n8n workflow data against the old data retrieved from the repository. If they do not match, the update process is initiated.
Create new file and commit (GitHub n8n node): Handles the creation of a new JSON file for an n8n workflow that did not previously exist in the repository.
Update file content and commit (GitHub n8n node): Edits and commits changes to an existing n8n workflow file, providing the required version control history.
Use this robust n8n workflow to automatically backup and version your production n8n workflows to a secondary n8n instance using the n8n API. Includes rolling retention and Notion tracking.

Use this robust n8n workflow to automatically backup all your existing n8n workflow designs daily to Google Drive. This n8n template ensures essential system redundancy and disaster recovery.

A comprehensive n8n workflow to automate daily backups of all your n8n workflows to a Bitbucket repository, ensuring version control and rate limit compliance.

Use this powerful n8n workflow to automatically backup all your decrypted n8n credentials to GitHub. Protect your data using this reliable n8n templates solution.









































