Templates / Backup All n8n Workflows to GitHub Nightly

Backup All n8n Workflows to GitHub Nightly

Intermediate   Apps: n8n API, GitHub  ·  Setup: 15 minutes

Your workflows ARE production code - they move leads, invoices, and alerts - but most instances have zero version control. One mis-click while editing and last month's working version is simply gone. This workflow calls n8n's own API nightly, pulls every workflow as JSON, and commits changed ones to a GitHub repo: full history, readable diffs, one-click restore by re-importing.

Download workflow JSON (free) Setup guide

What this workflow does

  1. A Schedule Trigger runs nightly at 2am.
  2. An HTTP Request node calls your instance's /api/v1/workflows endpoint with an API key.
  3. A Code node turns each workflow into a pretty-printed JSON file item, named by its slug.
  4. A GitHub node creates or updates each file in your backup repo - unchanged files produce no noise commits.

Setup guide

  1. Import the JSON into n8n (Workflows > Import from File).
  2. Create an n8n API key (Settings > n8n API) and set it in the HTTP Request node's header auth credential.
  3. Set your instance URL in the HTTP Request node (e.g. https://your-n8n.example.com/api/v1/workflows).
  4. Create a private GitHub repo, connect GitHub with a token (repo scope), and set owner/repo in the GitHub node.
  5. Activate - tomorrow morning your repo contains every workflow as JSON.

Want this running 24/7?

Self-host n8n on a cheap VPS and this workflow runs around the clock for less than a coffee a month.

Get an n8n VPS from $5/month

FAQ

Does it back up credentials too?No - and that's deliberate. The API exports workflow structure only; secrets stay in n8n's encrypted store. Back up your encryption key and database separately for full disaster recovery.
How do I restore a workflow?Open the file in GitHub, copy the JSON, and use Workflows > Import from Clipboard in n8n. For a point-in-time version, browse the file's commit history first.
Can it commit only when something changed?The GitHub file-edit operation always writes, but identical content produces an empty diff. To skip no-op commits entirely, add a GitHub get-file step and compare content in a Code node before writing.

Want the workflows this one is a warm-up for?

The Mega Bundle packs both WorkflowForge Pro volumes — 32 production-grade workflows: automations (cart recovery, lead scoring, invoice extraction) and AI agents (support agent, calendar assistant, research agent), each with a setup guide. $39 for both, instant download.

Get the Mega Bundle →

Need it customized for your exact process?

I build custom n8n automations and AI agents professionally: your tools, your edge cases, tested and documented.

Hire me on Fiverr →