Automated n8n Workflow Backup to GitHub Tutorial

Discover how to automate backing up your n8n workflows to GitHub with this step-by-step tutorial. Avoid data loss and streamline version control by saving your workflows as JSON files in a GitHub repository.
github
code
manualTrigger
+12
Workflow Identifier: 2294
NODES in Use: ManualTrigger, StickyNote, n8n, Set, HttpRequest, If, Merge, Code, Switch, NoOp, GitHub, SplitInBatches, ScheduleTrigger, ExecuteWorkflowTrigger, ExecuteWorkflow

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What This Workflow Does

This workflow saves copies of all n8n workflows automatically every 2 hours to a GitHub repository.
It solves the problem of losing workflows when they get accidentally changed or deleted.
The result is a backup of all workflows with version history on GitHub.

It helps prevent work loss and saves time by not needing to manually export workflows.


How It Works: Input, Process, Output

Inputs

  • n8n API: Provides current workflows.
  • GitHub API: Stores workflow JSON files.

Processing Steps

  • Fetch all workflows from n8n with API.
  • Split workflows one by one for checking.
  • Try fetching matching workflow file from GitHub.
  • If file is missing or large, handle accordingly.
  • Merge n8n and GitHub data for comparison.
  • Compare files to see if new, changed, or same.
  • Skip update if no change to save resources.
  • Create new file or update existing on GitHub if needed.

Outputs

  • Updated GitHub repo with backups of all workflows.
  • Version control history of workflow changes.

Who Should Use This Workflow

This is useful for users who manage many workflows in n8n.
Especially if workflows change frequently or multiple people edit them.

It helps anyone wanting automatic backups without manual exporting.
Also good for those needing version history and recovery options.


Tools and Services Used

  • n8n: The automation tool running the workflow.
  • GitHub API: For storing workflow files and managing versions.
  • GitHub Personal Access Token: To authenticate with GitHub.

Beginner Step-by-Step: How to Use This Workflow in n8n

Step 1: Import Workflow

  1. Download the workflow using the Download button on this page.
  2. Open the n8n editor (like self-host n8n if self hosting).
  3. Use the “Import from File” option to load the downloaded workflow.

Step 2: Configure Credentials and Settings

  1. Add your n8n API credentials in the appropriate node.
  2. Add your GitHub Personal Access Token with repo permissions.
  3. In the “Globals” node, update repo.owner, repo.name, and repo.path to your GitHub repository details.

Step 3: Test the Workflow

  1. Run the manual trigger named On clicking ‘execute’ to backup workflows immediately.
  2. Check your GitHub repo to confirm workflows are saved.

Step 4: Activate for Production

  1. Activate the Schedule Trigger to run every 2 hours automatically.
  2. Monitor run logs in n8n to confirm backups happen without errors.

Customization Ideas

  • Change how often backups run by editing the Schedule Trigger interval.
  • Organize backups by updating the folder path (repo.path) in the “Globals” node.
  • Add workflow metadata fields in the isDiffOrNew code node if extra info should be saved.
  • Improve large file handling with retry logic or alerts.
  • Include notifications after manual backups using email or Slack nodes.

Troubleshooting Common Issues

  • GitHub file fetch fails with ‘file not found’:
    Verify repository owner, name, and folder path in the “Globals” node are correct.
  • Existing file updates not committing:
    Check JSON comparison in isDiffOrNew code node to see if changes are detected.
  • Large workflow files not updating:
    Ensure fallback HTTP request for large files triggers correctly and GitHub token has correct scopes.

Pre-Production Checklist

  • Test GitHub credentials with simple read and write.
  • Check n8n API access by fetching workflow list manually.
  • Confirm manual trigger backs up workflows to GitHub.
  • Verify scheduled trigger runs every 2 hours.
  • Create manual backups of important workflows before activating automation.

Deployment Guide

Enable the Schedule Trigger node to start automatic backups every 2 hours.
Use manual trigger for testing or on-demand backups.

Watch workflow logs for errors and confirm GitHub files update.
Add notifications if needed to alert on backup success or failure.


Summary of Benefits

✓ Automatically saves all n8n workflows to GitHub every 2 hours.
✓ Protects against accidental workflow loss or overwrite.
✓ Keeps clear version history with minimal unnecessary commits.
✓ Saves user time by cutting manual exports.
✓ Easy to customize frequency, folders, and metadata.

Frequently Asked Questions

No, this workflow uses GitHub nodes and APIs only. To use GitLab, change nodes and authentication to GitLab API.
Yes, it calls GitHub API for reading and writing files. It limits calls by updating only when changes happen.
Yes, workflow JSON files are saved in a private GitHub repository. Keep GitHub tokens safe to protect data.
Check that repository owner, name, and path are correctly set in the Globals node and that the folder exists or is created.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free