Automate n8n Workflow Backups to GitHub Easily

Struggling to manually backup your n8n workflows leading to errors and lost configurations? This unique n8n workflow automates backing up all your workflows as JSON files to GitHub, saving you hours and ensuring your automation data is safe and versioned.
github
code
n8n
+12
Workflow Identifier: 1356
NODES in Use: Manual Trigger, Sticky Note, n8n, Set, Http Request, If, Merge, Code, Switch, No Operation, GitHub, Split In Batches, Schedule Trigger, Execute Workflow Trigger, Execute Workflow
Automate n8n workflow backups with GitHub

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

Learn how to Build this Workflow with AI:

1. What This Automation Does

This workflow automatically backs up all workflows from an n8n instance into a GitHub repository as JSON files.
It solves the problem of manual exporting and backups that waste lots of time and risk losing changes.
The result is that every workflow is saved safely and versioned in GitHub without extra work.

The workflow first collects a list of all workflows inside n8n.
It checks the GitHub repository to find existing backup files.

It compares the current workflow data with the backed-up version.
If a workflow is new or changed, it creates or updates the JSON file on GitHub.
If no change is detected, it skips that workflow to save time and API calls.

This logical check-and-commit method keeps backups accurate and does not flood GitHub with needless commits.
Status like “new,” “different,” or “same” controls the workflow behavior.


2. How the Workflow Works: Inputs, Processing, Outputs

Inputs

  • n8n instance workflows: Metadata list of all workflows currently active.
  • GitHub repository files: JSON backup files for each workflow stored under folders named by tags.

Processing Steps

  • Retrieve workflows from n8n API.
  • For each workflow, fetch existing backup file from GitHub repo.
  • Check if backup file exists; if not, mark as new.
  • Compare JSON structures with normalized keys to find differences.
  • Branch logic: skip if same, create file if new, or edit file if different.
  • Commit changes with meaningful messages including workflow names.

Outputs

  • Updated GitHub repository with backed-up workflows as JSON files.
  • GitHub commit history indicating changes over time.
  • Clean workflow execution results with status flags.

3. Who Should Use This Workflow

This workflow is great for anyone using n8n who want a simple way to protect workflows.
It helps users who forget to export or keep versions manually.

Small teams or automation users without complex DevOps setups gain a straightforward backup method.
People running self-host n8n also benefit from scheduled backups.


4. Tools and Services Used

  • n8n: The automation platform running workflows.
  • GitHub API: For reading and writing files in repository.
  • GitHub repository: Storage location for JSON workflow backups.

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

Download and Import

  1. Download the backup workflow using the Download button on this page.
  2. Open the n8n editor.
  3. Click “Import from File” and upload the downloaded workflow JSON.

Configure Credentials and Settings

  1. Add your GitHub API Key credentials in the GitHub nodes.
  2. Check the Globals node for GitHub repo info: update repo owner, name, and folder path if needed.
  3. Update any IDs, emails, or channels if this workflow integrates with other tools.

Test and Activate

  1. Run the workflow once manually using the manualTrigger node to check for errors.
  2. Verify backups appear correctly in your GitHub repository.
  3. Activate the workflow by enabling the Schedule Trigger node to run daily or at your preferred interval.

6. Customizations and Tips

  • Change backup folder path in the Globals node to organize backups by project or category.
  • Add extra metadata or dates inside JSON files by adjusting the isDiffOrNew Code node.
  • Run backups more often by modifying the schedule trigger settings.
  • Filter workflows by tags with the tag? switch node to backup only needed flows.
  • Swap GitHub credentials easily in GitHub nodes when using different tokens or accounts.

7. Troubleshooting Common Failures

GitHub API Rate Limit Exceeded

If backups run too often or many commits happen, GitHub blocks requests.
Reduce backup frequency or skip unchanged workflows to avoid this.

File Too Large to Download

The workflow has a fallback for big files but frequent triggers here may indicate very large workflows.
Consider splitting workflows or adjusting fallback logic.

Workflows Without Tags Saved in Root

If workflows have no tags, the backup files go into the root folder.
Add tags or update the path logic in the Globals node to change this.


8. Pre-Production Checklist

  • Check GitHub credentials have proper repo write permissions.
  • Manually test access to GitHub repo and confirm correct write access.
  • Run manual trigger and verify n8n workflow list is fetched correctly.
  • Confirm backups create or change files in GitHub repository as expected.
  • Test with workflows having tags and no tags to verify output paths.
  • Backup any existing GitHub repo content before first run as safety.

9. Deployment Guide

Enable the Schedule Trigger node to do backup every day or as needed.
Use manual run first to test and see file creation in GitHub.

Watch GitHub repo commits to track backup status.
Use execution logs in n8n if any step fails or doesn’t behave as expected.


10. Summary

✓ backs up all n8n workflows automatically to GitHub as JSON files
✓ detects new or changed workflows and updates backups only when needed
✓ saves time and reduces mistakes from manual export
✓ organizes backups by workflow tags for easy navigation
✓ provides history with GitHub commit records for version tracking

→ users get safe, versioned backups without extra effort
→ workflow runs cleanly with clear status messages
→ flexible for customization and scaling


Code Snippet for Comparing Workflows

The code below inside the isDiffOrNew Code node compares workflows properly by normalizing JSON keys.
It marks files as “same,” “different,” or “new,” and prepares content for new or changed files.

const orderJsonKeys = (jsonObj) => {
  const ordered = {};
  Object.keys(jsonObj).sort().forEach(key => {
    ordered[key] = jsonObj[key];
  });
  return ordered;
}

// Check if file returned with content
if (Object.keys($input.all()[0].json).includes("content")) {
  const origWorkflow = JSON.parse(Buffer.from($input.all()[0].json.content, 'base64').toString());
  const n8nWorkflow = $input.all()[1].json;
  
  const orderedOriginal = orderJsonKeys(origWorkflow);
  const orderedActual = orderJsonKeys(n8nWorkflow);

  if (JSON.stringify(orderedOriginal) === JSON.stringify(orderedActual)) {
    $input.all()[0].json.github_status = "same";
  } else {
    $input.all()[0].json.github_status = "different";
    $input.all()[0].json.n8n_data_stringy = JSON.stringify(orderedActual, null, 2);
  }
  $input.all()[0].json.content_decoded = orderedOriginal;
} else {
  const n8nWorkflow = $input.all()[1].json;
  const orderedActual = orderJsonKeys(n8nWorkflow);
  $input.all()[0].json.github_status = "new";
  $input.all()[0].json.n8n_data_stringy = JSON.stringify(orderedActual, null, 2);
}

return $input.all();

Automate n8n workflow backups with GitHub

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

This workflow specifically uses GitHub API nodes. For other services like GitLab or Bitbucket, users must modify it to use their API with HTTP requests.
Using the splitInBatches node helps reduce memory use by handling workflows one at a time, but very large workflows may take longer to process.
Yes. Data transfers use secure GitHub API connections. Keep GitHub API keys private to maintain security.
Add at least one tag to workflows or update the backup file path in the Globals node to specify a default folder for untagged flows.

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.