{
  "name": "Automated workflow backup to Google Drive with smart cleanup",
  "nodes": [
    {
      "id": "b7a4ebea-711b-473d-b18a-7bf84a888a17",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1456,
        -72
      ]
    },
    {
      "id": "c7d51e5b-0add-4c66-8d85-e98d3a09f72e",
      "name": "Manual trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1456,
        -264
      ]
    },
    {
      "id": "73b8a7f5-d038-4366-b30b-a92195db3a35",
      "name": "Search files and folders",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -16,
        -480
      ]
    },
    {
      "id": "adc967fc-746c-462c-9de8-f823100d833d",
      "name": "Start cleanup (run once)",
      "type": "n8n-nodes-base.set",
      "position": [
        -240,
        -480
      ]
    },
    {
      "id": "1f4ad497-fbf8-4053-80fc-f22c9200370c",
      "name": "Sort and isolate old folders",
      "type": "n8n-nodes-base.code",
      "position": [
        208,
        -480
      ]
    },
    {
      "id": "ff6c6c87-2751-4429-a196-edc65f898e43",
      "name": "Loop over folders to delete",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        432,
        -480
      ]
    },
    {
      "id": "7669d1df-6225-47aa-841b-c14f48cbd2e3",
      "name": "Loop over each workflow",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -560,
        -144
      ]
    },
    {
      "id": "c7a911aa-e8a2-42a3-a64b-5c2c4318720a",
      "name": "Get all n8n workflows",
      "type": "n8n-nodes-base.n8n",
      "position": [
        -784,
        -144
      ]
    },
    {
      "id": "20acb740-7157-4e30-bd4d-04b8663a8f8d",
      "name": "Create new backup folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -1008,
        -144
      ]
    },
    {
      "id": "82b9a618-2765-4c53-baa7-66a025808c2d",
      "name": "Convert workflow to file",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        -240,
        16
      ]
    },
    {
      "id": "1f14d31c-9ab6-4b4f-b054-a02f1b75336f",
      "name": "Upload workflow to Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -16,
        16
      ]
    },
    {
      "id": "db4893e5-8a63-4d3d-9067-6a6d68ed3119",
      "name": "Delete old folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        656,
        -480
      ]
    },
    {
      "id": "d6769f88-ffc4-4c1d-b8be-082109b12dde",
      "name": "CONFIG - Set your variables here",
      "type": "n8n-nodes-base.set",
      "position": [
        -1232,
        -144
      ]
    },
    {
      "id": "06268a9d-854e-47ee-b6f5-38c8dd57ee20",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2112,
        -336
      ],
      "parameters": {
        "width": 560,
        "height": 432,
        "content": "## How to find your Google Drive Folder ID\nTo tell the workflow where to save your backups, you need to provide the ID of a parent folder in your Google Drive.\n\n1.  Go to [Google Drive](https://drive."
      }
    },
    {
      "id": "1907cd86-02d6-473a-a605-4518d83c2b1b",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -336,
        -608
      ],
      "parameters": {
        "width": 1168,
        "height": 336,
        "content": "## Cleanup Logic: Finds and deletes old backup folders\nThis first part of the workflow handles automatic maintenance. It searches for all existing backup folders in your Google Drive, sorts them by cr"
      }
    },
    {
      "id": "dcad82b1-69e9-484f-8d06-cadc311a5ac7",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -336,
        -208
      ],
      "parameters": {
        "width": 544,
        "height": 432,
        "content": "## Backup Logic: Fetches all workflows and uploads them to a new daily folder\nThis is the core backup process. It begins by creating a new, dated folder for the current day's backup. It then fetches a"
      }
    },
    {
      "id": "fb976047-3811-437a-b19c-de8def3fe06c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2736,
        -560
      ],
      "parameters": {
        "width": 560,
        "height": 848,
        "content": "## Backup n8n workflows to Google Drive with automatic cleanup\n\nThis template automates the process of backing up all your n8n workflows to Google Drive, ensuring you always have a safe copy of your a"
      }
    }
  ],
  "connections": {
    "Manual trigger": {
      "main": [
        [
          {
            "node": "CONFIG - Set your variables here",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "CONFIG - Set your variables here",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete old folder": {
      "main": [
        [
          {
            "node": "Loop over folders to delete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get all n8n workflows": {
      "main": [
        [
          {
            "node": "Loop over each workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop over each workflow": {
      "main": [
        [
          {
            "node": "Start cleanup (run once)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Convert workflow to file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert workflow to file": {
      "main": [
        [
          {
            "node": "Upload workflow to Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create new backup folder": {
      "main": [
        [
          {
            "node": "Get all n8n workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search files and folders": {
      "main": [
        [
          {
            "node": "Sort and isolate old folders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start cleanup (run once)": {
      "main": [
        [
          {
            "node": "Search files and folders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop over folders to delete": {
      "main": [
        [],
        [
          {
            "node": "Delete old folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sort and isolate old folders": {
      "main": [
        [
          {
            "node": "Loop over folders to delete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload workflow to Google Drive": {
      "main": [
        [
          {
            "node": "Loop over each workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CONFIG - Set your variables here": {
      "main": [
        [
          {
            "node": "Create new backup folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}