{
  "name": "Automated n8n workflow backup to GitHub with deletion tracking",
  "nodes": [
    {
      "id": "638dcc28-8b20-40e6-81fd-96efec4d4111",
      "name": "On clicking 'execute'",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        260,
        640
      ]
    },
    {
      "id": "287eabd3-013d-41cd-a9c3-ae71b8d26ef9",
      "name": "Return",
      "type": "n8n-nodes-base.set",
      "position": [
        1800,
        1680
      ]
    },
    {
      "id": "edc8da3b-fcf1-4487-8963-464c18c209b5",
      "name": "Get File",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        920,
        1140
      ]
    },
    {
      "id": "63859d24-34b7-4545-a3fb-fe45b3678cef",
      "name": "If file too large",
      "type": "n8n-nodes-base.if",
      "position": [
        700,
        1160
      ]
    },
    {
      "id": "8509afb5-c772-445d-af47-de54c9deae6e",
      "name": "isDiffOrNew",
      "type": "n8n-nodes-base.code",
      "position": [
        920,
        1420
      ]
    },
    {
      "id": "ac50a21b-f850-495a-9e41-8fdd075c3c62",
      "name": "Same file - Do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1360,
        1600
      ]
    },
    {
      "id": "293179e5-9ef0-4f75-b39c-987ebf13a9b5",
      "name": "File is different",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1360,
        1420
      ]
    },
    {
      "id": "ab03b5e9-61eb-4512-9675-afd048a761c6",
      "name": "File is new",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1360,
        1240
      ]
    },
    {
      "id": "a0431fdb-41ff-4bf0-8618-c743d6be159e",
      "name": "Create new file",
      "type": "n8n-nodes-base.github",
      "position": [
        1580,
        1240
      ]
    },
    {
      "id": "e0a9e1f0-bd40-4009-8945-24a264ddbf0d",
      "name": "Edit existing file",
      "type": "n8n-nodes-base.github",
      "position": [
        1580,
        1420
      ]
    },
    {
      "id": "a4d50217-3d8c-48f3-a486-fb3c033fcef4",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1580,
        740
      ]
    },
    {
      "id": "4f529f31-26a2-4f19-b8f3-42ce583b11ad",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        260,
        840
      ]
    },
    {
      "id": "c8c0bc8a-3538-4c63-8882-3dd846830649",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        480
      ],
      "parameters": {
        "width": 371,
        "height": 601,
        "content": "## Backup to GitHub \nThis workflow will backup all instance workflows to GitHub and also deleted it if was deleted in n8n.\n\nThe files are saved `ID.json` for the filename.\n\n### Setup\nOpen `Globals` no"
      }
    },
    {
      "id": "d527bac6-971b-4be7-8481-97dd023e85e1",
      "name": "Get file data",
      "type": "n8n-nodes-base.github",
      "position": [
        480,
        1160
      ]
    },
    {
      "id": "6c7b66fa-bfdd-47ea-9161-835415d116dd",
      "name": "Execute Workflow Trigger",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -100,
        1540
      ]
    },
    {
      "id": "a3021ade-6778-49df-8ad4-4d43f28d51e2",
      "name": "Execute Workflow",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        1800,
        740
      ]
    },
    {
      "id": "e6675677-07ac-48d9-a920-58065cc79d77",
      "name": "Globals",
      "type": "n8n-nodes-base.set",
      "position": [
        480,
        740
      ]
    },
    {
      "id": "fba69d35-d05b-45a1-bdd9-93a83fddf63e",
      "name": "List files",
      "type": "n8n-nodes-base.github",
      "position": [
        1140,
        840
      ]
    },
    {
      "id": "f235efb7-3ff9-497d-bc32-c94f38f76183",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        120,
        1540
      ]
    },
    {
      "id": "7c35c3da-b364-4ad0-b192-3691cb73eb6f",
      "name": "Get many workflows",
      "type": "n8n-nodes-base.n8n",
      "position": [
        700,
        740
      ]
    },
    {
      "id": "12a90225-5a32-4b69-bee6-d61bc4369eb2",
      "name": "Workflows",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        920,
        840
      ]
    },
    {
      "id": "799e5c1f-43aa-4375-b8f2-25a3335ddb18",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        700,
        1420
      ]
    },
    {
      "id": "5acad04e-0c07-4663-be6f-d8cdf4ecee4e",
      "name": "Check Status",
      "type": "n8n-nodes-base.switch",
      "position": [
        1140,
        1420
      ]
    },
    {
      "id": "a5979392-d277-4580-aa16-09d18e3eb577",
      "name": "isDeleted",
      "type": "n8n-nodes-base.code",
      "position": [
        920,
        1740
      ]
    },
    {
      "id": "c08dde95-3a3a-4ac1-a92b-c9bcd5c7743b",
      "name": "Delete a file",
      "type": "n8n-nodes-base.github",
      "position": [
        1580,
        1860
      ]
    },
    {
      "id": "1e769761-5f93-4d67-b801-e2d6a8443aed",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        1140,
        1740
      ]
    },
    {
      "id": "39ad6ee3-acde-4019-b850-7a8add4e795a",
      "name": "n8n",
      "type": "n8n-nodes-base.set",
      "position": [
        1360,
        640
      ]
    },
    {
      "id": "fc83af27-10a8-4ec4-94e7-15ab074c8ab6",
      "name": "github",
      "type": "n8n-nodes-base.set",
      "position": [
        1360,
        840
      ]
    },
    {
      "id": "99e64b8f-3446-4b74-8ce6-5eccd47d0aa7",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        460,
        600
      ],
      "parameters": {
        "width": 150,
        "height": 80,
        "content": "## Edit this node 👇"
      }
    },
    {
      "id": "734112c4-9175-4f50-a2d6-7970d2938624",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        180,
        480
      ],
      "parameters": {
        "width": 1831,
        "height": 601,
        "content": "## Main workflow loop"
      }
    },
    {
      "id": "0dbfd9fc-e5c8-4a98-8435-5a44c1f3d56d",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        1100
      ],
      "parameters": {
        "width": 2231,
        "height": 941,
        "content": "## Subworkflow"
      }
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Delete a file",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Return",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "n8n": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "isDiffOrNew",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Return": {
      "main": [
        []
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Get file data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ],
        [
          {
            "node": "isDeleted",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "github": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Globals": {
      "main": [
        [
          {
            "node": "Get many workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get File": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflows": {
      "main": [
        [
          {
            "node": "List files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "isDeleted": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List files": {
      "main": [
        [
          {
            "node": "github",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File is new": {
      "main": [
        [
          {
            "node": "Create new file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "isDiffOrNew": {
      "main": [
        [
          {
            "node": "Check Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Status": {
      "main": [
        [
          {
            "node": "File is new",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "File is different",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Same file - Do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete a file": {
      "main": [
        [
          {
            "node": "Return",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get file data": {
      "main": [
        [
          {
            "node": "If file too large",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create new file": {
      "main": [
        [
          {
            "node": "Return",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Execute Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Globals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File is different": {
      "main": [
        [
          {
            "node": "Edit existing file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If file too large": {
      "main": [
        [
          {
            "node": "Get File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit existing file": {
      "main": [
        [
          {
            "node": "Return",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get many workflows": {
      "main": [
        [
          {
            "node": "Workflows",
            "type": "main",
            "index": 0
          },
          {
            "node": "n8n",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On clicking 'execute'": {
      "main": [
        [
          {
            "node": "Globals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Same file - Do nothing": {
      "main": [
        [
          {
            "node": "Return",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow Trigger": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}