{
  "id": "qNt1EP9LpXpmPsrR",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Workflow Backup copy",
  "tags": [],
  "nodes": [
    {
      "id": "8a1a1151-af5f-4143-8748-c5a7e7df41e0",
      "name": "Convert to File",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        1000,
        220
      ],
      "parameters": {
        "options": {
          "format": true,
          "fileName": "={{ $json.name + \".json\" }} "
        },
        "operation": "toJson"
      },
      "typeVersion": 1.1
    },
    {
      "id": "2eeed47c-ab3e-4b8c-9cbc-4cbefa6fb59f",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        0,
        260
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9fd17067-54c0-4d59-91c1-8d69d87bae6e",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "position": [
        1340,
        0
      ],
      "parameters": {
        "options": {
          "ignoreCase": true
        },
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "538fc29d-2693-4c62-9848-bdcaf8566909",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.id }}",
              "rightValue": "={{ $('Create new folder').item.json.id }}"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "632da5d2-eae3-4930-8024-6875d995ac7b",
      "name": "delete folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1560,
        0
      ],
      "parameters": {
        "options": {
          "deletePermanently": true
        },
        "resource": "folder",
        "operation": "deleteFolder",
        "folderNoRootId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "23999fdb-5501-4c75-9359-a63d72036e51",
      "name": "Get folders",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1120,
        0
      ],
      "parameters": {
        "filter": {
          "folderId": {
            "__rl": true,
            "mode": "list",
            "value": ""
          }
        },
        "options": {},
        "resource": "fileFolder"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "81ad6d55-c569-42e5-93a0-9a2549080749",
      "name": "Manual trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "db6e17c9-374a-4a14-9a83-97733becff11",
      "name": "Create new folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        200,
        0
      ],
      "parameters": {
        "name": "=Workflow Backups {{ $now.format('cccc t dd-MM-yyyy') }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1DHzXsjyUvDJsZssbX_kgHHLrvls3-_jA",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1DHzXsjyUvDJsZssbX_kgHHLrvls3-_jA",
          "cachedResultName": "backup n8n"
        },
        "resource": "folder"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "393ac68c-f005-443c-ac5c-69679e0e3041",
      "name": "Loop ",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        600,
        0
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "92f0685e-f093-40d0-ace0-523f97c4c1fe",
      "name": "Upload workflow",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1180,
        220
      ],
      "parameters": {
        "name": "={{ $('Loop ').item.json.name + \".json\" }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create new folder').item.json.id }}"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "63204c20-fb38-4459-a925-28c3cfb8bf78",
      "name": "Limit",
      "type": "n8n-nodes-base.limit",
      "position": [
        920,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "5f6b7108-e2f6-4e83-8644-6c6f96d22964",
      "name": "Get n8n workflow",
      "type": "n8n-nodes-base.n8n",
      "position": [
        400,
        0
      ],
      "parameters": {
        "filters": {},
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "11719b22-f8ed-45cc-946d-90393a6af706",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1840,
        -340
      ],
      "parameters": {
        "color": 4,
        "width": 1320,
        "height": 1660,
        "content": "# \ud83d\udd04 Workflow Backup for n8n \u2192 Google Drive\n\nAn automated system to back up all your n8n workflows and store them as `.json` files in Google Drive.  \nPerfect for creators, teams, and agencies who want to protect their work without manual effort.\n\n---\n\n## \u2728 What this workflow does\n\n- Creates a new folder in Google Drive named `Workflow Backups [date]`\n- Fetches all workflows from your n8n instance via the `n8n API`\n- Converts each workflow into a `.json` file\n- Uploads the files to the created backup folder\n- (Optionally) Deletes old backup folders to keep things tidy\n- Can run manually or automatically (e.g., weekly)\n\n---\n\n## \ud83d\udee0 Requirements\n\n- A Google account with access to Google Drive\n- Connected `Google Drive OAuth2` credentials in n8n\n- Active `n8n API credentials`\n- Enabled trigger: `Manual` or `Schedule`\n\n---\n\n## \u2699\ufe0f Installation Instructions\n\n1. **Import the workflow** (`Workflow_Backup_copy.json`) into your n8n instance\n2. **Set up credentials:**\n   - Replace `Google demo` with your own `Google Drive OAuth2` in the following nodes:\n     - `Create new folder`\n     - `Get folders`\n     - `Upload workflow`\n     - `delete folder`\n   - Replace `n8n demo` with your `n8n API` credentials in `Get n8n workflow`\n3. **Replace the folder ID** in the `Create new folder` node with the target backup folder on your Drive (`folderId`)\n4. **Optional:** Configure `Schedule Trigger` to run weekly or at your preferred interval\n\n---\n\n## \ud83d\udce6 Workflow Structure\n\n```\nManual/Schedule Trigger\n      \u2193\nCreate new folder (Google Drive)\n      \u2193\nGet n8n workflows (via API)\n      \u2193\nLoop through workflows\n      \u2193\nConvert to .json files\n      \u2193\nUpload to Drive\n      \u2193\n(Optional) Delete old backup folders\n```\n\n---\n\n## \u2705 Tips\n\n- Add logic to retain only the latest X backups (e.g., last 3).\n- The workflow can run fully hands-free once scheduled.\n- Want to store files elsewhere? Swap out the upload node for Dropbox, S3, etc.\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "timezone": "Europe/Warsaw",
    "callerPolicy": "workflowsFromSameOwner",
    "executionOrder": "v1"
  },
  "versionId": "b5965021-a283-4c62-bf51-b9be920327c6",
  "connections": {
    "Limit": {
      "main": [
        [
          {
            "node": "Get folders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop ": {
      "main": [
        [
          {
            "node": "Limit",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "delete folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get folders": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manual trigger": {
      "main": [
        [
          {
            "node": "Create new folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Upload workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload workflow": {
      "main": [
        [
          {
            "node": "Loop ",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get n8n workflow": {
      "main": [
        [
          {
            "node": "Loop ",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Create new folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create new folder": {
      "main": [
        [
          {
            "node": "Get n8n workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}