⚙️ Back up workflows daily to GitHub with incremental updates

⚡ 21 views · ⚙️ DevOps & CI/CD

💡 Pro Tip — If you need GitHub data beyond what the REST API gives you, ScraperNode has a repository scraper that extracts metadata at scale without token rate limits.

View All Scrapers

Description

Quick overview

This workflow runs nightly to back up all workflows from your n8n instance to a GitHub repository, creating a new JSON file for new workflows and only updating existing files when the workflow has changed to avoid unnecessary commits.

How it works

  1. Runs every day at 11 PM on a schedule trigger.
  2. Retrieves a list of all workflows in your n8n instance using the n8n API and processes them one by one.
  3. Checks GitHub to see whether a backup JSON file already exists for the current workflow.
  4. If no file exists, fetches the full workflow JSON from n8n and creates a new file in the GitHub repository.
  5. If a file exists, calls the GitHub Commits API to get the latest commit date for that file and compares it to the workflow’s updatedAt date in n8n.
  6. If n8n is newer, downloads the latest workflow JSON and updates the existing file on GitHub; otherwise it skips updating to avoid creating a commit.
  7. Waits 10 seconds between GitHub operations to reduce the chance of hitting GitHub API rate limits.

Setup

  1. Create an n8n API key and add an n8n API credential, then select it in the n8n nodes that list and fetch workflows.
  2. Create a GitHub Personal Access Token with repo access and add a GitHub credential, then select it in the GitHub and GitHub-authenticated HTTP request steps.
  3. Replace YOUR_GITHUB_USERNAME and YOUR_BACKUP_REPO in all GitHub-related settings, including the Commits API URL.
  4. Ensure your target repository has a workflows/ folder (or allow the workflow to create files under that path) and verify the filename pattern works with your workflow names.

Requirements

Customization

Additional info

The workflow is incremental by design: it compares each workflow’s last update against the latest GitHub commit and only writes when something actually changed, keeping commit history clean and avoiding needless writes.

Brand-new workflows are created; existing changed ones are edited in place, so file history stays intact per workflow.

Before first run, do a manual test execution to confirm the n8n API key and GitHub token are both authorized — the Get/Create/Edit file nodes will surface auth errors early.

🔗 Nodes Used

GitHub, HTTP Request, n8n, Schedule Trigger

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup