Templates / Back up and restore n8n workflows with GitHub sync

Back up and restore n8n workflows with GitHub sync

Ready for 3.0

by Muhammad Anas Farooq ✓ · 423 views · created 2026-01-15 · DevOps

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.

Nodes used (12)

GitHub

What it does

n8n Workflows GitHub Manager > A comprehensive n8n workflow that provides complete bidirectional sync between your n8n instance and GitHub - automatically backs up all your workflows with intelligent change detection AND restores them when needed. This workflow combines two powerful features in one: Backup: Automatically detects new, edited, renamed, and deleted workflows in your n8n instance, then syncs them to GitHub with smart commit messages and an index tracking system. Restore: Easily restore all workflows from your GitHub repository back to n8n - perfect for disaster recovery, new instance setup, or environment cloning. --- How It Works 🔄 Backup Mode (Automatic) 1. Trigger: Runs automatically every day at 7 PM UTC (or manually when triggered via the Schedule Trigger). 2. Get/Create Index: Attempts to fetch index.json from your GitHub repository. If found → Downloads and parses it. If not found → Creates a new empty index file and waits 3 seconds for GitHub to process. 3. Fetch All Workflows: Retrieves all workflows from your n8n instance via the n8n API. 4. Smart Comparison: The "C,E,D Checker" (Create, Edit, Delete) analyzes differences: CREATE → New workflow not in index. RENAME → Workflow name changed (deletes old file, creates new one). EDIT → Existing workflow (flagged for content comparison). DELETE → Workflow removed from n8n but still in GitHub. INDEX UPDATE → Triggered if any changes detected. 5. Route Actions: Switch node routes each action to the appropriate branch: Create Branch → Creates new workflow files in GitHub. Edit Branch → Performs smart edit detection: Fetches current file from GitHub. Compares GitHub version vs. n8n version (normalized JSON). Only commits if content actually changed (avoids timestamp-only updates). Delete Branch → Removes workflow files from GitHub. Update Index Branch → Updates index.json with latest mappings. 6. Commit Messages: Auto-generated with format: Workflow Name (Action) YYYY-MM-DD ⬇️ Restore Mode (Manual) 1. Trigger: Manually execute via the "When clicking 'Execute workflow'" manual trigger. 2. Set GitHub Details: Configure your repository owner and name. 3. List Workflow Files: Fetches all workflow JSON files from the workflows/ folder in your GitHub repository. If folder not found → Workflow stops gracefully (ensure backup ran at least once first). 4. Loop Through Files: Sequentially processes each workflow file: Downloads the JSON content from GitHub. Creates the workflow in your n8n instance via the n8n API. 5. Sequential Processing: Handles one workflow at a time to prevent conflicts and respect rate limits. 6. Result: All workflows from GitHub are restored to your n8n instance. --- Requirements GitHub OAuth2 Credentials: Go to GitHub Developer Settings → OAuth Apps → New OAuth App. Set Authorization callback URL to your n8n instance URL (e.g., https://your-n8n.com/rest/oauth2-credential/callback). Copy Client ID and Client Secret. Add as OAuth2 credential in n8n (Credentials → New → GitHub OAuth2). GitHub Repository: Create a new repository (public or private). Note your username (repo owner) and repository name. n8n API Credentials: In your n8n instance → Settings → API → Create new API key. Add as n8n API credential in the workflow. --- How to Use Initial Setup 1. Import the Workflow: Copy the provided JSON file. In your n8n instance → click Import Workflow → paste or upload the JSON. 2. Create GitHub Repository: Go to GitHub → Create a new repository (e.g., n8n-workflows-manager). Leave it empty (no README, no .gitignore). 3. Set Up GitHub OAuth2: In n8n → Credentials → New → GitHub OAuth2. Fill in: Client ID → from GitHub OAuth App. Client Secret → from GitHub OAuth App. Click Connect my account and authorize. 4. Set Up n8n API Credentials: In n8n → Settings → API → Create new API key. Copy the key. In workflow → Credentials → New → n8n API → paste the key. Set Base URL to your n8n instance (e.g., https://your-n8n.com). 5. Configure Repository Details: Fin

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.