{
  "id": "dJTNsUj85pNl2Yze",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Back up n8n workflows to Google Drive automatically",
  "tags": [
    {
      "id": "HtlI91CxAap27ehf",
      "name": "n8n",
      "createdAt": "2026-01-14T06:09:05.926Z",
      "updatedAt": "2026-01-14T06:09:05.926Z"
    }
  ],
  "nodes": [
    {
      "id": "eaaf07eb-5c1f-4b3e-8c39-0b134bd26371",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -480,
        -224
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "targetFloderId"
            },
            {
              "name": "workflows",
              "type": "array"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "d1e0cdde-ce3e-44cc-afe0-85588218449d",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        464,
        -224
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "joinMode": "keepEverything",
        "fieldsToMatchString": "workflowId"
      },
      "typeVersion": 3.2
    },
    {
      "id": "f73d55d1-1463-48db-bcd7-093883a33b19",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -272,
        -48
      ],
      "parameters": {
        "include": "allOtherFields",
        "options": {},
        "fieldToSplitOut": "workflows"
      },
      "typeVersion": 1
    },
    {
      "id": "ffa57db2-d5a3-4e20-9713-37a2f086d14e",
      "name": "Convert to File",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        80,
        -48
      ],
      "parameters": {
        "mode": "each",
        "options": {
          "fileName": "={{ $json.workflows.name }}(#{{ $json.workflows.id }}).json"
        },
        "operation": "toJson",
        "binaryPropertyName": "=data"
      },
      "typeVersion": 1.1
    },
    {
      "id": "2083e6a8-1da9-4d28-8dd2-ed7647da3a93",
      "name": "Call 'n8n auto-backup to google drive'",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        272,
        -672
      ],
      "parameters": {
        "mode": "each",
        "options": {
          "waitForSubWorkflow": false
        },
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "kNBofPjNI2bsqxNl7yRNu",
          "cachedResultUrl": "/workflow/kNBofPjNI2bsqxNl7yRNu",
          "cachedResultName": "n8n auto-backup to google drive"
        },
        "workflowInputs": {
          "value": {
            "workflows": "={{ $json.workflows }}",
            "targetFloderId": "={{ $json.targetFloderId }}"
          },
          "schema": [
            {
              "id": "targetFloderId",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "targetFloderId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "workflows",
              "type": "array",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "workflows",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "2efea638-b0a4-49ab-ba70-4f5ae7c0ccbc",
      "name": "Get n8n host 1",
      "type": "n8n-nodes-base.n8n",
      "position": [
        -272,
        -672
      ],
      "parameters": {
        "filters": {},
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "eaf07076-7777-4e47-8851-6c0477f7b9ab",
      "name": "Get n8n host 2",
      "type": "n8n-nodes-base.n8n",
      "position": [
        -272,
        -512
      ],
      "parameters": {
        "filters": {
          "activeWorkflows": true
        },
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "324ca755-8ad7-434f-a6ba-723d8c3a51d5",
      "name": "Update workflow",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1072,
        -80
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.driveFileId }}"
        },
        "options": {},
        "operation": "update",
        "changeFileContent": true,
        "newUpdatedFileName": "={{ $json.workflowName }}"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "d2c0f780-981a-4835-b5aa-583809be68e2",
      "name": "Upload workflow",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1072,
        -240
      ],
      "parameters": {
        "name": "={{ $json.workflowName }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.targetFloderId }}"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "bac0f453-0131-4079-a2b2-3702ac3ab56e",
      "name": "Get file list",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -272,
        -224
      ],
      "parameters": {
        "filter": {
          "whatToSearch": "all"
        },
        "options": {
          "fields": [
            "*"
          ]
        },
        "resource": "fileFolder",
        "returnAll": true,
        "queryString": "='{{ $json.targetFloderId }}' in parents and trashed = false",
        "searchMethod": "query"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": false,
      "typeVersion": 3,
      "alwaysOutputData": true
    },
    {
      "id": "bb0261bf-17c9-4921-b985-bea714440dd0",
      "name": "Extract file information",
      "type": "n8n-nodes-base.set",
      "position": [
        80,
        -224
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a1405730-a480-47b5-8be7-ccaff35babb6",
              "name": "driveFileId",
              "type": "string",
              "value": "={{ $json.id }}"
            },
            {
              "id": "6e48e441-f4f0-4e1d-9e82-f89b95240cb1",
              "name": "driveFileModiedTime",
              "type": "string",
              "value": "={{ $json.modifiedTime }}"
            },
            {
              "id": "5c39cfb4-874b-425d-858a-bdc6ecbaf6b8",
              "name": "workflowId",
              "type": "string",
              "value": "={{ $json.name.match(/\\(#(.+)\\)/)[1] }}"
            },
            {
              "id": "8fede18f-58f2-4ff0-9bbe-f4940bf8fbca",
              "name": "driveMimeType",
              "type": "string",
              "value": "={{ $json.kind }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "1f904463-9853-4b11-9173-7f6181390442",
      "name": "Set Workflow Name",
      "type": "n8n-nodes-base.set",
      "position": [
        256,
        -48
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "0c77254f-4515-44f5-9be5-d1cc0b034147",
              "name": "workflowName",
              "type": "string",
              "value": "={{ $('Filter archived workflows').item.json.workflows.name }}(#{{ $('Filter archived workflows').item.json.workflows.id }}).json"
            },
            {
              "id": "2429fadb-8cfb-4766-85c5-aabd64a5e2d0",
              "name": "workflows",
              "type": "object",
              "value": "={{ $('Filter archived workflows').item.json.workflows }}"
            },
            {
              "id": "e40eed22-ad21-4968-bb93-2f4843db636f",
              "name": "targetFloderId",
              "type": "string",
              "value": "={{ $('Filter archived workflows').item.json.targetFloderId }}"
            },
            {
              "id": "fb6f4a9c-64ce-4b6b-996f-78fab2c215e1",
              "name": "workflowId",
              "type": "string",
              "value": "={{ $('Filter archived workflows').item.json.workflows.id }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "efedcf69-ffba-4d63-aaed-18c2bae65c82",
      "name": "Filter files",
      "type": "n8n-nodes-base.filter",
      "position": [
        256,
        -224
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "537acb73-4aaf-49f6-9520-c40e121634b8",
              "operator": {
                "type": "string",
                "operation": "notEndsWith"
              },
              "leftValue": "={{ $('Get file list').item.json.mimeType }}",
              "rightValue": "folder"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "37a35d66-b399-49d8-844c-84e07c122c0e",
      "name": "Filter files by update time",
      "type": "n8n-nodes-base.filter",
      "position": [
        640,
        -224
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "d27cb6a2-a530-4456-8e1b-5bd7647dce9d",
              "operator": {
                "type": "dateTime",
                "operation": "beforeOrEquals"
              },
              "leftValue": "={{ $json.driveFileModiedTime || 0 }}",
              "rightValue": "={{ $json.workflows.updatedAt }}"
            },
            {
              "id": "8ec84b2d-9b54-43c4-9194-2dc2f4648c6b",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "551b273c-138e-4337-93e5-f4582b0e0910",
      "name": "Run daily",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -480,
        -672
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "ec695355-9b8f-4430-9947-dbdbeda1a2a0",
      "name": "Batch Host 1 data",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -80,
        -672
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "workflows"
      },
      "typeVersion": 1
    },
    {
      "id": "f11c8a5c-06f1-49c3-a951-05721803bc1b",
      "name": "Batch Host 2 data",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -80,
        -512
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "workflows"
      },
      "typeVersion": 1
    },
    {
      "id": "eea2b1a3-0570-4b3b-8aef-43832596c6b8",
      "name": "Route: New vs Update",
      "type": "n8n-nodes-base.if",
      "position": [
        848,
        -224
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e3b3547b-a1c9-4cd1-a14d-71b9f15d326f",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $('Merge')?.item?.json['driveFileId'] || \"\" }}",
              "rightValue": ""
            },
            {
              "id": "0f4c89fa-89d7-4d30-a284-0766ec0ec20c",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "78f52864-679e-44a7-9b19-5a008bb62c3e",
      "name": "Filter archived workflows",
      "type": "n8n-nodes-base.filter",
      "position": [
        -96,
        -48
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "65aaea42-ce31-4329-9661-b738a787c4ee",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              },
              "leftValue": "={{ $json.workflows.isArchived }}",
              "rightValue": false
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "cee9c9be-6306-42a7-b438-d1a4d669bea4",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1056,
        -768
      ],
      "parameters": {
        "width": 496,
        "height": 912,
        "content": "## \ud83d\udcd8 How it works\nThis workflow provides a robust, automated backup solution for one or multiple n8n instances, syncing your workflows directly to Google Drive with version history support.\n\nIt operates in two main stages:\n1. **Fetch & Dispatch**: The workflow runs on a schedule (e.g., daily). It connects to your configured n8n instances via the n8n Public API to retrieve all active workflows.\n2. **Smart Sync**: It recursively processes the workflows for each instance. It compares the local workflows against the files in your specified Google Drive folder.\n   - **New Workflows**: Automatically uploaded as JSON files.\n   - **Updated Workflows**: If a workflow has been modified since the last backup, the existing file on Drive is updated. This leverages Google Drive's native version history, allowing you to roll back changes if needed.\n   - **Unchanged Workflows**: Skipped to save bandwidth and API calls.\n\n## \ud83d\udcdd Setup steps\n1. **Credentials**: Configure your **n8n API** credentials for each instance you want to back up, and your **Google Drive OAuth2** credentials.\n2. **Folder Setup**: Create a folder in Google Drive for each n8n instance. Copy the `Folder ID` from the browser URL for each.\n3. **Configuration**:\n   - In the \"Config Host\" nodes (Set nodes), paste your Google Drive `Folder ID`.\n   - Ensure the \"Process backup recursively\" node is set to call *this* workflow's ID (or the specific sub-workflow ID if you separated them).\n4. **Schedule**: Enable the Schedule Trigger to start backing up automatically."
      },
      "typeVersion": 1
    },
    {
      "id": "1e9ef960-69c4-400e-bb31-29dfa1da91ff",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -528,
        -768
      ],
      "parameters": {
        "color": 4,
        "width": 1008,
        "height": 416,
        "content": "## \u23f1\ufe0f 1. Fetch & Dispatch \nRuns on a schedule to fetch workflow data from multiple n8n instances."
      },
      "typeVersion": 1
    },
    {
      "id": "6ceb4f47-bf96-4381-9a45-8b421605855f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -528,
        -320
      ],
      "parameters": {
        "color": 6,
        "width": 1840,
        "height": 464,
        "content": "## \ud83d\udcbe 2. Core Backup Logic \nHandles the comparison, version control, and file upload to Google Drive."
      },
      "typeVersion": 1
    },
    {
      "id": "6df58a3a-186c-4813-afcb-b74ce903d87c",
      "name": "Config Host 2",
      "type": "n8n-nodes-base.set",
      "position": [
        96,
        -512
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "17ab4866-04c9-48b5-93d8-6698e7fe84f1",
              "name": "targetFloderId",
              "type": "string",
              "value": ""
            },
            {
              "id": "7a5eb81f-589a-4327-8531-a6fead1d6656",
              "name": "workflows",
              "type": "array",
              "value": "={{ $json.workflows }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d715c26f-78e7-4f47-9e47-3dd5c44e018e",
      "name": "Config Host 1",
      "type": "n8n-nodes-base.set",
      "position": [
        96,
        -672
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "17ab4866-04c9-48b5-93d8-6698e7fe84f1",
              "name": "targetFloderId",
              "type": "string",
              "value": ""
            },
            {
              "id": "7a5eb81f-589a-4327-8531-a6fead1d6656",
              "name": "workflows",
              "type": "array",
              "value": "={{ $json.workflows }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    }
  ],
  "active": false,
  "settings": {
    "timezone": "Etc/UTC",
    "callerPolicy": "workflowsFromSameOwner",
    "timeSavedMode": "fixed",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "3eae3547-0e20-4f13-bacb-588c58ac5d55",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Filter files by update time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run daily": {
      "main": [
        [
          {
            "node": "Get n8n host 2",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get n8n host 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Filter archived workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter files": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Config Host 1": {
      "main": [
        [
          {
            "node": "Call 'n8n auto-backup to google drive'",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Config Host 2": {
      "main": [
        [
          {
            "node": "Call 'n8n auto-backup to google drive'",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get file list": {
      "main": [
        [
          {
            "node": "Extract file information",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get n8n host 1": {
      "main": [
        [
          {
            "node": "Batch Host 1 data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get n8n host 2": {
      "main": [
        [
          {
            "node": "Batch Host 2 data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Set Workflow Name",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Batch Host 1 data": {
      "main": [
        [
          {
            "node": "Config Host 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Batch Host 2 data": {
      "main": [
        [
          {
            "node": "Config Host 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Workflow Name": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Route: New vs Update": {
      "main": [
        [
          {
            "node": "Upload workflow",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract file information": {
      "main": [
        [
          {
            "node": "Filter files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter archived workflows": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter files by update time": {
      "main": [
        [
          {
            "node": "Route: New vs Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Get file list",
            "type": "main",
            "index": 0
          },
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}