{
  "name": "Back up and restore n8n workflows with GitHub sync",
  "nodes": [
    {
      "id": "66f1d868-3d2f-4d01-a44d-65a1683c60a2",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        960,
        -336
      ]
    },
    {
      "id": "6683f526-0831-457c-9b3d-9149b6aa72c4",
      "name": "Create Index File",
      "type": "n8n-nodes-base.github",
      "position": [
        1808,
        -176
      ]
    },
    {
      "id": "ef2313ca-a8d4-4518-bd7e-72500c90a6bc",
      "name": "Get Download Url for Index File",
      "type": "n8n-nodes-base.github",
      "position": [
        1360,
        -336
      ]
    },
    {
      "id": "8643952a-3860-451c-96e3-4e4271c2bec0",
      "name": "Get Index File Content",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1584,
        -352
      ]
    },
    {
      "id": "b4d05bc7-36de-4cf3-9ff0-dac7faff26a2",
      "name": "Index File Not Found",
      "type": "n8n-nodes-base.if",
      "position": [
        1584,
        -160
      ]
    },
    {
      "id": "f5544061-062b-4a5a-b98b-f8c274e78104",
      "name": "Set Github Data",
      "type": "n8n-nodes-base.set",
      "position": [
        1168,
        -336
      ]
    },
    {
      "id": "dfd491c1-6c20-4c99-801a-867d5b1e6376",
      "name": "When clicking ‘Execute workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        992,
        752
      ]
    },
    {
      "id": "fb17c3b6-5501-4f1f-bd78-10b39d3cc135",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        2016,
        -176
      ]
    },
    {
      "id": "8d2a68af-641f-43ff-96c0-5e4d1a3d419f",
      "name": "Get All Workflows",
      "type": "n8n-nodes-base.n8n",
      "position": [
        1792,
        -352
      ]
    },
    {
      "id": "ca083a23-d014-4623-8375-a58ed5cc4a08",
      "name": "C,E,D Checker",
      "type": "n8n-nodes-base.code",
      "position": [
        2016,
        -352
      ]
    },
    {
      "id": "2ed6483e-158f-4865-aa19-8d9a6a9ad9a1",
      "name": "Create New Files",
      "type": "n8n-nodes-base.github",
      "position": [
        2544,
        -624
      ]
    },
    {
      "id": "61fedd05-149c-4257-9de2-5cc784009ade",
      "name": "Update Index File",
      "type": "n8n-nodes-base.github",
      "position": [
        2544,
        -64
      ]
    },
    {
      "id": "0df1da12-7855-43c5-a039-7f9ec057ca4f",
      "name": "Get Download Url for Github File",
      "type": "n8n-nodes-base.github",
      "position": [
        2544,
        -464
      ]
    },
    {
      "id": "3b665fc8-6273-4223-ab7a-b1ab1cb524f8",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        2224,
        -384
      ]
    },
    {
      "id": "4ca08961-1c75-4d40-8f85-203ef0e5ce1c",
      "name": "Delete Files",
      "type": "n8n-nodes-base.github",
      "position": [
        2544,
        -240
      ]
    },
    {
      "id": "d9be1383-2cbe-467d-95b6-5193fd01080e",
      "name": "Get Github File Content",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2800,
        -464
      ]
    },
    {
      "id": "a8b185c6-dd27-407a-8156-8fd3b10bbb65",
      "name": "Parse Github File Content",
      "type": "n8n-nodes-base.code",
      "position": [
        3024,
        -464
      ]
    },
    {
      "id": "a54da607-6234-4661-960e-1954b72d28a9",
      "name": "File Edit Checker",
      "type": "n8n-nodes-base.code",
      "position": [
        3472,
        -448
      ]
    },
    {
      "id": "a830aab5-48fe-4e9f-a836-6a70dce2d625",
      "name": "Merge Github & n8n File",
      "type": "n8n-nodes-base.merge",
      "position": [
        3248,
        -448
      ]
    },
    {
      "id": "623fafcc-e4c7-4643-bfde-6b618cb39bd7",
      "name": "If File Edited",
      "type": "n8n-nodes-base.if",
      "position": [
        3696,
        -448
      ]
    },
    {
      "id": "00098dfc-2bc6-4492-9562-8122a536954f",
      "name": "Edit Files",
      "type": "n8n-nodes-base.github",
      "position": [
        3920,
        -464
      ]
    },
    {
      "id": "23b09a8a-983f-477f-be9a-96fe59dca49f",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        864,
        -896
      ],
      "parameters": {
        "width": 3270,
        "height": 1443,
        "content": "# n8n-Workflow-Github-Backup"
      }
    },
    {
      "id": "81fe00c0-4469-4f57-a8e7-441b5619b754",
      "name": "Workflow Summary",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        -48
      ],
      "parameters": {
        "width": 512,
        "height": 416,
        "content": "## 📋 WORKFLOW SUMMARY\n\n**Purpose:** Automatically backup n8n workflows to GitHub\n\n**Flow:**\n1. Trigger (Schedule/Manual)\n2. Get/Create index.json in GitHub\n3. Fetch all n8n workflows\n4. Compare with G"
      }
    },
    {
      "id": "8d64b719-713f-4f0c-9054-55707357fab2",
      "name": "Setup Requirements",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        -704
      ],
      "parameters": {
        "width": 500,
        "height": 608,
        "content": "## ⚙️ SETUP REQUIREMENTS\n\n**1️⃣ GitHub OAuth Credentials**\n- Go to *Credentials → New → GitHub OAuth2*\n- Create GitHub OAuth App:\n  - Settings → Developer settings → OAuth Apps\n  - Authorization callb"
      }
    },
    {
      "id": "3fd029b9-9573-4f10-b464-333728f5791a",
      "name": "Index System",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1632,
        32
      ],
      "parameters": {
        "width": 420,
        "height": 472,
        "content": "## 📂 INDEX SYSTEM\n\n**index.json structure:**\n```json\n{\n  \"workflow_id_1\": {\n    \"name\": \"Workflow Name\",\n    \"file_path\": \"workflows/Workflow Name.json\"\n  },\n  \"workflow_id_2\": { ... }\n}\n```\n\n**Purpos"
      }
    },
    {
      "id": "9ab1adc8-5de8-4eba-9128-aed991abae8c",
      "name": "C,E,D Checker Logic",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1808,
        -848
      ],
      "parameters": {
        "width": 400,
        "height": 456,
        "content": "## 🔍 C,E,D CHECKER\n\n**Compare & Decision Logic:**\n\nFor each n8n workflow:\n- **CREATE:** New workflow not in index\n- **RENAME:** Workflow name changed\n  - Deletes old file\n  - Creates new file with new"
      }
    },
    {
      "id": "3e687dee-c761-4cfc-b7b0-301e414a0cf8",
      "name": "Switch Routing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2128,
        16
      ],
      "parameters": {
        "width": 360,
        "height": 496,
        "content": "## 🔀 SWITCH ROUTING\n\nRoutes items based on status:\n\n**Create Branch:**\n- New workflows → Create New Files\n\n\n**Edit Branch:**\n- Existing workflows → Smart edit check\n- Fetches GitHub version\n- Compares"
      }
    },
    {
      "id": "fc8aa3ca-ab5b-463a-ba87-40a10e7486e1",
      "name": "Smart Edit Detection",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3456,
        -288
      ],
      "parameters": {
        "width": 380,
        "height": 428,
        "content": "## ✏️ SMART EDIT DETECTION\n\n**Why needed:**\n- n8n changes timestamps/metadata on save\n- Prevents unnecessary commits\n\n\n**Process:**\n1. Fetch current file from GitHub\n2. Parse both GitHub & n8n version"
      }
    },
    {
      "id": "52fef552-2ada-4451-8909-08dcc301a6d2",
      "name": "Commit Messages",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2832,
        -240
      ],
      "parameters": {
        "width": 360,
        "height": 404,
        "content": "## 📝 COMMIT MESSAGES\n\nAuto-generated commit messages:\n\n**Format:** `[Workflow Name] ([Action]) YYYY-MM-DD`\n\n**Examples:**\n- `My Workflow (Created) 2026-01-15`\n- `My Workflow (Edited) 2026-01-15`\n- `My"
      }
    },
    {
      "id": "a9f5ca79-fb19-436b-92e7-87f167759636",
      "name": "Workflows Folder Not Found",
      "type": "n8n-nodes-base.if",
      "position": [
        1632,
        976
      ]
    },
    {
      "id": "a2bb07be-ea57-4098-8f2e-94b62cdaf00b",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1632,
        736
      ]
    },
    {
      "id": "0715c423-09e1-4743-84bf-0c3f133810e5",
      "name": "Get File Content",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1872,
        752
      ]
    },
    {
      "id": "bff04c86-1ace-4b5b-9ab6-bbe4f146846b",
      "name": "List Workflow Files",
      "type": "n8n-nodes-base.github",
      "position": [
        1408,
        752
      ]
    },
    {
      "id": "1ec8abd6-051a-411f-a889-15bc605a8afb",
      "name": "Create Workflow",
      "type": "n8n-nodes-base.n8n",
      "position": [
        2096,
        752
      ]
    },
    {
      "id": "e839c8ca-d8cc-47cb-9ceb-05b9235e6e94",
      "name": "How It Works",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        944
      ],
      "parameters": {
        "width": 400,
        "height": 284,
        "content": "## 🔄 HOW IT WORKS\n\n**Sequential Processing:**\n- Loops through files one at a time\n- Downloads JSON from GitHub\n- Creates workflow in n8n\n- Prevents conflicts and rate limits\n\n**Error Handling:**\n- If "
      }
    },
    {
      "id": "782b9b5e-067b-4fb1-ba54-64d2f6c813c4",
      "name": "Set Github Data1",
      "type": "n8n-nodes-base.set",
      "position": [
        1200,
        752
      ]
    },
    {
      "id": "a02ef593-96ca-42d1-b072-e96d82b044f8",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        864,
        592
      ],
      "parameters": {
        "width": 1494,
        "height": 675,
        "content": "# n8n-Workflow-Github-Restore"
      }
    },
    {
      "id": "9910bb0d-581e-4a82-94ad-3e2066c99625",
      "name": "Workflow Summary1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        416,
        592
      ],
      "parameters": {
        "width": 416,
        "height": 372,
        "content": "## 📋 WORKFLOW SUMMARY\n\n**Purpose:** Restore n8n workflows from GitHub backup\n\n**Flow:**\n1. Manual trigger\n2. Set GitHub repo details\n3. List workflow files from GitHub\n4. Loop through each file\n5. Dow"
      }
    }
  ],
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Set Github Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Create New Files",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Download Url for Github File",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge Github & n8n File",
            "type": "main",
            "index": 1
          }
        ],
        [
          {
            "node": "Delete Files",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update Index File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "C,E,D Checker": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If File Edited": {
      "main": [
        [
          {
            "node": "Edit Files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Workflow": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Get File Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Github Data": {
      "main": [
        [
          {
            "node": "Get Download Url for Index File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get File Content": {
      "main": [
        [
          {
            "node": "Create Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Set Github Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Github Data1": {
      "main": [
        [
          {
            "node": "List Workflow Files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Index File": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File Edit Checker": {
      "main": [
        [
          {
            "node": "If File Edited",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get All Workflows": {
      "main": [
        [
          {
            "node": "C,E,D Checker",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List Workflow Files": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Workflows Folder Not Found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Index File Not Found": {
      "main": [
        [
          {
            "node": "Create Index File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Index File Content": {
      "main": [
        [
          {
            "node": "Get All Workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Github File Content": {
      "main": [
        [
          {
            "node": "Parse Github File Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Github & n8n File": {
      "main": [
        [
          {
            "node": "File Edit Checker",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Github File Content": {
      "main": [
        [
          {
            "node": "Merge Github & n8n File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Download Url for Index File": {
      "main": [
        [
          {
            "node": "Get Index File Content",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Index File Not Found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Download Url for Github File": {
      "main": [
        [
          {
            "node": "Get Github File Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Set Github Data1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}