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
Automate n8n workflow backup to GitHub

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

Learn how to Build this Workflow with AI:

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.

Automate n8n workflow backup to GitHub

Visit through Desktop to Interact with the Workflow.

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 Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.