n8n

How to Automate GitHub n8n Backups for Version Control?

Keep your automations safe with daily version control. Each night, your n8n workflows are saved as JSON files in a GitHub repo. Teams gain history, audit trails, and fast recovery without manual exports.

A schedule runs at 23:59. The flow pulls all workflows from your n8n REST API and then fetches full data for each item. It also reads the current file list from GitHub and downloads file contents. Two compare steps match workflow names with file names. New items are saved as new JSON files. Existing items are updated through an edit action with a clean commit message. Simple function steps split arrays into single items so matching stays accurate.

You need a GitHub repo and a token with repo scope, plus your n8n URL with basic auth. Set the owner and repository fields in the GitHub nodes, and point the HTTP requests to your n8n base URL. Expect backups to run in minutes and cut manual work by most of the hour you would spend. Useful for change reviews, rollback, and compliance records.

What are the key features?

  • Daily schedule at 23:59 to run backups automatically
  • Fetches all workflows from the n8n REST API using Basic Auth
  • Function steps split arrays into single items for easy matching
  • Reads GitHub repository file list and downloads raw contents
  • Merge logic compares workflow names to detect new and existing files
  • Creates new JSON files for new workflows with clear commit messages
  • Edits existing GitHub files when workflows change to keep versions current
  • Uses a GitHub token and n8n credentials to secure each request

What are the benefits?

  • Reduce manual backup work from 60 minutes to 5 minutes
  • Automate 100% of daily workflow exports
  • Improve backup accuracy by up to 95% by removing copy paste errors
  • Connect n8n and GitHub to centralize workflow history
  • Handle dozens of workflows with no extra effort

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with GitHub and n8n. See the Tools Required section above for links to create accounts with these services.
  3. In GitHub, create a personal access token with repo scope. In n8n, open the Credentials manager, create a GitHub credential, and paste the token. If unsure, double click any GitHub node, choose 'Credential to connect with' > 'Create new credential' and follow the on screen steps.
  4. Open the Create file and GitHub Edit nodes. Set the owner and repository fields to your GitHub repo. Optionally choose the branch if you do not use the default branch.
  5. Open the Get Files node and set the same owner and repository. Keep the file path as the folder where you want the JSON backups to live.
  6. Create an HTTP Basic Auth credential for your n8n instance. Use the username and password that protect your n8n REST API. Attach this credential to the Get workflows and Get workflow data nodes.
  7. Update the URLs in Get workflows and Get workflow data to match your base URL. For n8n Cloud, use https://your-subdomain.n8n.cloud/rest/workflows and /rest/workflows/{{id}}.
  8. Create an HTTP Header Auth credential with your GitHub token and attach it to the Download Raw Content node so it can read file contents from private repos.
  9. Open the Daily at 23:59 node to adjust the schedule and timezone if needed. Pick a time that fits your maintenance window.
  10. Test the setup: click Execute Workflow once. In your GitHub repo, confirm new JSON files appear with names that match your workflow names and that commit messages are correct.
  11. Edit any n8n workflow name or content, run the workflow again, and check that the file is updated in GitHub rather than duplicated.
  12. If you see 401 errors, recheck credentials and token scopes. If files do not appear, verify repository name, branch, and that the URLs point to the right n8n instance. Save and activate the workflow when everything looks good.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

GitHub

Sign up

Free tier: $0 / mo

n8n API

Sign up

Community Edition (self-hosted): $0 (public REST API available). Cloud Starter: $20 / mo billed annually ($24 monthly); API unavailable during free trial.

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.