GitHub backups that keep your builds versioned
You only notice missing backup history when something breaks. A workflow gets edited, overwritten, or deleted, and suddenly you are hunting for “the last good version” that nobody can find.
Ops leads feel it during incidents. Agency owners feel it when a client asks “what changed?” and you have no clean answer. Even a marketing team running n8n for lead routing runs into the same problem, which is why GitHub backup automation is so handy.
This workflow backs up every n8n workflow to GitHub on a schedule, keeps version history tidy, and makes rollback realistic. You’ll see how it works, what you need, and where teams usually trip up.
How This Automation Works
The full n8n workflow, from trigger to final output:
n8n Workflow Template: GitHub backups that keep your builds versioned
flowchart LR
subgraph sg0["Schedule Flow"]
direction LR
n0@{ icon: "mdi:cog", form: "rounded", label: "Move Binary Data", pos: "b", h: 48 }
n1@{ icon: "mdi:play-circle", form: "rounded", label: "Schedule Trigger", pos: "b", h: 48 }
n2["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/github.dark.svg' width='40' height='40' /></div><br/>Edit a file"]
n3["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/httprequest.dark.svg' width='40' height='40' /></div><br/>Get All Workflows"]
n4["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/github.dark.svg' width='40' height='40' /></div><br/>Create a file"]
n5@{ icon: "mdi:swap-horizontal", form: "rounded", label: "If file not exits?", pos: "b", h: 48 }
n6["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/merge.svg' width='40' height='40' /></div><br/>Get Previous FIle back"]
n2 --> n5
n0 --> n2
n0 --> n6
n1 --> n3
n3 --> n0
n5 --> n6
n6 --> n4
end
%% Styling
classDef trigger fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
classDef ai fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
classDef aiModel fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
classDef decision fill:#fff8e1,stroke:#f9a825,stroke-width:2px
classDef database fill:#fce4ec,stroke:#c2185b,stroke-width:2px
classDef api fill:#fff3e0,stroke:#e65100,stroke-width:2px
classDef code fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
classDef disabled stroke-dasharray: 5 5,opacity: 0.5
class n1 trigger
class n5 decision
class n3 api
classDef customIcon fill:none,stroke:none
class n2,n3,n4,n6 customIcon
The Problem: Your workflow history disappears when you need it most
n8n makes it easy to build fast, which is great right up until it isn’t. Teams tweak a production workflow “real quick,” someone duplicates and edits the wrong copy, or a cleanup deletes more than intended. Then the questions start. What did we change last week? Which version was running when leads stopped syncing? Can we restore the workflow without rebuilding it from scratch? Manually exporting JSON once in a while helps, but it’s inconsistent, easy to forget, and usually stored in the least reliable place imaginable (a desktop folder named “final-final”).
The friction compounds. Here’s where it breaks down.
- Exports happen after someone remembers, so the most important changes often never get captured.
- When a workflow is corrupted or deleted, recovery turns into a slow rebuild instead of a quick restore.
- Without GitHub commits, there’s no trustworthy timeline of edits to review during troubleshooting.
- Teams avoid improving automations because they’re scared to touch a fragile “working” setup.
The Solution: Automatic n8n exports committed to GitHub every 6 hours
This n8n workflow runs on a schedule every 6 hours and creates a fresh snapshot of all your current workflows. It pulls the workflow list from your n8n instance via an HTTP request, converts that JSON into a file format GitHub can store cleanly, and then pushes it into your chosen repository. If a backup file already exists, it updates it; if it’s missing, the workflow creates it. Each run produces a time-stamped commit message, so you can scroll history, compare changes, and restore a known-good version without guessing. Honestly, it’s the kind of automation you set up once and then forget until the day it saves you.
The workflow starts with a scheduled trigger, then it retrieves every workflow as JSON. That snapshot is converted into a file and sent to GitHub, with simple logic to handle “update vs. create” and keep the repo orderly.
What You Get: Automation vs. Results
| What This Workflow Automates | Results You’ll Get |
|---|---|
|
|
Example: What This Looks Like
Say your team maintains 30 workflows and makes changes most days. Manually exporting them weekly can take about 5 minutes per workflow (find it, export, name it, store it), so roughly 2.5 hours a week, and it still misses mid-week changes. With this setup, the “manual” part is basically zero after initial configuration: the trigger runs every 6 hours, GitHub gets a commit, and you have about 4 restore points per day. When a workflow gets broken at 3pm, you can roll back to the noon snapshot instead of rebuilding.
What You’ll Need
- n8n instance (try n8n Cloud free)
- Self-hosting option if you prefer (Hostinger works well)
- GitHub for storing versioned backup files.
- n8n API access to export your workflow list.
- n8n API key (generate it in your n8n user settings).
Skill level: Intermediate. You’ll paste credentials, set an API endpoint URL, and verify the repo path is correct.
Don’t want to set this up yourself? Talk to an automation expert (free 15-minute consultation).
How It Works
A scheduled run kicks everything off. The workflow uses a Schedule Trigger to start automatically every 6 hours, so backups aren’t tied to someone’s memory.
Your n8n instance exports the current truth. An HTTP Request pulls the full workflow list as JSON from your n8n API endpoint, using your API key for access.
The snapshot is turned into a storable file. n8n converts the JSON into a binary file so GitHub can store it as a proper artifact, not a half-broken copy/paste blob.
GitHub gets an update or a brand-new file. The workflow attempts to update the repository file first, checks if the file is missing, merges prior context if needed, and then creates the backup when required. The end result is a commit you can browse and restore from.
You can easily modify the schedule interval to match your change volume based on your needs. See the full implementation guide below for customization options.
Step-by-Step Implementation Guide
Step 1: Configure the Schedule Trigger
Set up the workflow to run automatically on a recurring schedule.
- Add the Scheduled Automation Start node as the trigger.
- Set the Rule to run every 6 hours by configuring Interval with Field =
hoursand Hours Interval =6. - Connect Scheduled Automation Start to Retrieve Workflow List.
Step 2: Connect the n8n API Source
Pull the full workflow list from your n8n instance using an authenticated API call.
- Select Retrieve Workflow List.
- Set URL to
https://your-n8n-instance.com/rest/workflows?limit=9999. - Enable Send Headers and add header parameters: accept =
application/jsonand X-N8N-API-KEY =[CONFIGURE_YOUR_API_KEY]. - Connect Retrieve Workflow List to Convert JSON to Binary.
[CONFIGURE_YOUR_API_KEY] with your actual n8n API key.Step 3: Convert JSON and Handle Parallel Processing
Transform the workflow list into a binary file and split processing into two parallel paths.
- Select Convert JSON to Binary and set Mode to
jsonToBinary. - In Options, set File Name to
=backupand enable Use Raw Data. - Confirm that Convert JSON to Binary outputs to both Update Repository File and Merge Prior Backup in parallel.
Step 4: Configure GitHub Backup Outputs
Send the binary backup to GitHub and handle first-time file creation.
- Open Update Repository File and set Resource to
fileand Operation toedit. - Set Owner to
github-profile-name, Repository ton8n_backup, and File Path tobackup.json. - Enable Binary Data and set Commit Message to
=n8n_backup_{{ $now.format('yyyy-MM-dd hh') }}. - Credential Required: Connect your githubApi credentials in Update Repository File.
- Configure Check Missing File to detect missing file errors with the condition Left Value =
{{ $json.error }}and Right Value =The resource you are requesting could not be found. - Set Merge Prior Backup to Mode =
combine, Join Mode =enrichInput1, and Fields To Match =data. - Configure Generate Backup File with the same repository settings and Commit Message =
=n8n_backup_{{ $now.format('yyyy-MM-dd hh') }}. - Credential Required: Connect your githubApi credentials in Generate Backup File.
Step 5: Test and Activate Your Workflow
Run a manual test to verify the backup file is created or updated correctly.
- Click Execute Workflow to trigger a manual run from Scheduled Automation Start.
- Confirm that Retrieve Workflow List returns data and Convert JSON to Binary produces a binary file.
- Verify that either Update Repository File successfully edits
backup.jsonor the fallback path creates it through Generate Backup File. - Open your GitHub repository and check for a commit message like
n8n_backup_YYYY-MM-DD hh. - Activate the workflow so Scheduled Automation Start runs every 6 hours in production.
Common Gotchas
- GitHub credentials can expire or need specific permissions. If things break, check the token scopes in GitHub and the n8n credential test result first.
- If you’re using Wait nodes or external rendering, processing times vary. Bump up the wait duration if downstream nodes fail on empty responses.
- Default prompts in AI nodes are generic. Add your brand voice early or you’ll be editing outputs forever.
Frequently Asked Questions
About 30 minutes if your GitHub repo and n8n API key are ready.
No. You’ll mostly paste credentials and confirm a few repo settings. The logic is already built into the workflow.
Yes. n8n has a free self-hosted option and a free trial on n8n Cloud. Cloud plans start at $20/month for higher volume. You’ll also need to factor in GitHub costs (usually free for this use case).
Two options: n8n Cloud (managed, easiest setup) or self-hosting on a VPS. For self-hosting, Hostinger VPS is affordable and handles n8n well. Self-hosting gives you unlimited executions but requires basic server management.
Yes, and it’s a quick change. Update the schedule in the “Scheduled Automation Start” node to run daily instead of every 6 hours. Common customizations include changing the backup file path, writing to a dedicated branch, or splitting backups so each workflow becomes its own file for easier diffs.
Most of the time it’s an expired token or a token without the right repo permissions. Regenerate your GitHub token, confirm it has access to the repository you’re writing to, then update the credential in n8n and re-test. Also double-check the repo owner/name and file path fields, because a tiny typo can look like an auth problem. If you’re running many automations, you can also hit GitHub rate limits, so spacing runs out (or reducing writes) helps.
A lot, as long as your n8n instance can export them and GitHub can accept the file size. On n8n Cloud, your limit is mostly your monthly execution quota (Starter and above scales up). If you self-host, there’s no execution cap, so it comes down to your server resources and how big your workflow library is.
Usually, yes. Zapier and Make aren’t designed for “export everything from n8n, transform it, then write it to GitHub with conditional file handling,” so you end up duct-taping steps and paying more as volume grows. n8n is also happy self-hosted, which matters when you want frequent backups without worrying about task limits. The bigger win is control: you can add branching, merge logic, and extra safety checks without fighting the platform. If you only need a simple two-step “export to storage” flow, Zapier or Make might feel easier. Talk to an automation expert if you want a quick recommendation for your setup.
Once this is running, you stop treating workflow history like a “nice to have.” You get a dependable trail in GitHub and a practical way back when mistakes happen.
Need Help Setting This Up?
Our automation experts can build and customize this workflow for your specific needs. Free 15-minute consultation—no commitment required.