Copia de seguridad y eliminación de flujos de trabajo usando n8n API y disparadores de formulario en Google Drive

Intermedio

Este es unDevOpsflujo de automatización del dominio deautomatización que contiene 13 nodos.Utiliza principalmente nodos como N8n, Code, Telegram, FormTrigger, GoogleDrive. Usar la API de n8n y disparadores de formularios para respaldar y eliminar flujos de trabajo en Google Drive

Requisitos previos
  • Bot Token de Telegram
  • Credenciales de API de Google Drive

Categoría

Vista previa del flujo de trabajo
Visualización de las conexiones entre nodos, con soporte para zoom y panorámica
Exportar flujo de trabajo
Copie la siguiente configuración JSON en n8n para importar y usar este flujo de trabajo
{
  "meta": {
    "instanceId": "0a82a9d5784b67ad963ceff89283b2e40cb771be10fe58ba2682f3598a37c6e1",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "76cdbf3e-e25b-4998-bf56-6cd13140e166",
      "name": "Al enviar el formulario",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        0,
        80
      ],
      "webhookId": "350d8518-e91c-4fd0-af83-b6649e7965bd",
      "parameters": {
        "options": {
          "buttonLabel": "Backup & Delete",
          "appendAttribution": false
        },
        "formTitle": "🧾 Backup & Delete Workflow",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Paste the full workflow URL below.",
              "placeholder": " https://n8n-miinstancia.com/workflow/abc123",
              "requiredField": true
            }
          ]
        },
        "formDescription": "This tool backs up the full JSON file of a workflow to a Google Drive folder before safely deleting it from your n8n instance."
      },
      "typeVersion": 2.2
    },
    {
      "id": "10ef7ab2-86ca-4e62-b94f-77a6e18f920d",
      "name": "Enviar un mensaje de texto",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1936,
        80
      ],
      "webhookId": "192a1c25-6efc-465a-b77d-c250fee9a57b",
      "parameters": {
        "text": "=✅ Workflow Backup Successful\n\nThe workflow titled: {{ $json.name }} \nwith ID: {{ $json.id }} \nhas been successfully backed up to your selected Google Drive Folder.\n\n📄 You can view the backup at the following link:\n(USE YOUR GOOGLE DRIVE FOLDER LINK HERE)\n\n📅 Backup Date: {{ $now }}\n",
        "chatId": "8019473661",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "BjU1NgO9AIM86N5W",
          "name": "EMPTY"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b038653e-afd6-4c59-b291-7caddf8cca7a",
      "name": "Nota adhesiva",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -768,
        -560
      ],
      "parameters": {
        "width": 624,
        "height": 1360,
        "content": "## 🔍 Description:\nEffortlessly delete unused or inactive workflows from your n8n instance while automatically backing them up as .json files into your Google Drive. Keep your instance clean, fast, and organized — no more clutter slowing you down. This workflow is ideal for users managing large self-hosted n8n setups, or anyone who wants to maintain optimal performance while preserving full workflow backups.\n\n## ✅ What it does:\n* Accepts a full n8n Workflow URL via a form\n* Retrieves workflow info automatically\n* Converts the workflow’s full JSON definition into a file\n* Uploads that file to Google Drive\n* Deletes the workflow safely using the official n8n API\n* Sends a Telegram notification confirming backup and deletion\n\n## ⚙️ How it works:\n📝 Form – Collects the full workflow URL from the user\n🔍 n8n Node (Get Workflow) – Uses the URL to fetch workflow details\n📦 Code Node (\"JSON to File\") – Converts the workflow JSON into a properly formatted .json file with UTF-8 encoding, ready to be uploaded to Google Drive.\n☁️ Google Drive Upload – Uploads the .json backup file to your selected Drive folder\n🗑️ n8n Node (Delete Workflow) – Deletes the workflow from your instance using its ID\n📬 Telegram Notification – Notifies you that the workflow was backed up and deleted, showing title, ID, and date\n\n## 📋 Requirements:\n* Google Drive connected to your n8n account\n* Telegram Bot connected to n8n\n* An n8n instance with API access (self-hosted or Cloud)\n* Your n8n API Key (Create one in the settings)\n\n## 🛠️ How to Set Up:\n✅ Add your Google Drive credentials\n✅ Add your Telegram Bot credentials\n\n🧾 In the “JSON to File” Code node, no additional setup is required — it automatically converts the workflow JSON into a downloadable .json file using the correct encoding and filename format.\n\n☁️ In the Google Drive node:\nBinary Property: data\nFolder ID: your target folder in Google Drive\n\n🔑 Create a new credential for the n8n node using:\nAPI Key: your personal n8n API key\nBase URL: your full n8n instance API path (e.g. https://your-n8n-instance.com/api/v1)\n⚙️ Use this credential in both the Get Workflow and Delete Workflow n8n nodes\n\n📬 In the Telegram node, use this message template:\n🗑️ Workflow \"{{ $json.name }}\" (ID: {{ $json.id }}) was backed up to Google Drive and deleted from n8n.\n📅 {{ $now }}\n\n🔒 Important: This workflow backs up the entire workflow data to Google Drive. Please be careful with the permissions of your Google Drive folder and avoid sharing it publicly, as the backups may contain sensitive information. Ensuring proper security and access control is essential to protect your data.\n\n🚀 Activate the workflow and you're ready to safely back up and remove workflows from your n8n instance\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "9da23a3f-d899-4eab-a12e-17ff8fa3c816",
      "name": "Nota adhesiva1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 1360,
        "content": "## 📝 1. Form Node: \"Get Workflow URL\"\n\n* Instruction: Ask the user to paste the full workflow URL they want to delete. This URL will be passed to the next node for processing.\n\n* Example input: https://your-n8n-instance/workflow/abcd1234\n\n* [See the Form Submission node documentation.](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.formtrigger/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.formTrigger)\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "2ed52c3b-1898-4c06-adc2-d81708ae3679",
      "name": "Nota adhesiva2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 1360,
        "content": "## 🔍 2. n8n Node: \"Get Workflow\"\n\n* Instruction: Use the official n8n node with API Key authentication to fetch full workflow details using the ID extracted from the URL.\n\n* Requirement: API Key Auth credentials configured with your API Key and Base URL (e.g., https://your-n8n-instance/api/v1).\n\n* [See the n8n node documentation.](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.n8n/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.n8n)"
      },
      "typeVersion": 1
    },
    {
      "id": "775f86f7-2daf-45ae-9ab6-0bf6a1ab56ef",
      "name": "Nota adhesiva4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1040,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 1360,
        "content": "## 📁 Google Drive Node: \"Upload Workflow Backup\"\n\nInstruction: Upload the binary file containing the workflow JSON backup to a specified folder in Google Drive. Configure folder ID and file name dynamically if needed.\n\n* [See the Google Drive node documentation.](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.googledrive/file-operations/#upload-a-file)"
      },
      "typeVersion": 1
    },
    {
      "id": "fc18f562-569a-48fa-9faa-14b0dc6349db",
      "name": "Nota adhesiva5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1424,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 1360,
        "content": "## 🗑️ 5. n8n Node: \"Delete Workflow\"\n\n* Instruction: Delete the workflow from your instance using its ID. Use the same API Key Auth credentials as in step 2.\n\n* [See the n8n node documentation.](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.n8n/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.n8n)"
      },
      "typeVersion": 1
    },
    {
      "id": "e19ae6be-61e2-414b-af70-2069dc3925a5",
      "name": "Nota adhesiva6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1808,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 1360,
        "content": "## 📬 6. Telegram Node: \"Send Notification\"\n\n* Instruction: Send a Telegram message confirming the workflow was backed up and deleted successfully. Include the workflow name, ID, date, and a link to the backup in Google Sheets.\n\n* [See the Telegram node documentation.](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.telegram/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.telegram)"
      },
      "typeVersion": 1
    },
    {
      "id": "cbef6523-6186-4a83-b70c-5b3c4a619615",
      "name": "Cargar flujo de trabajo",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1168,
        80
      ],
      "parameters": {
        "name": "={{ $('Get a Workflow').item.json.name }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1Wv8HI8jUu-XbpC4mRJH78WNMAD_xM8f8",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1Wv8HI8jUu-XbpC4mRJH78WNMAD_xM8f8",
          "cachedResultName": "N8N - Deleted Workflows Backup"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "Ru2YSsIPYQIOlnvD",
          "name": "EMPTY"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "e31a574e-a952-43f0-89cc-e385e46f6075",
      "name": "Nota adhesiva7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        656,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 1360,
        "content": "## 📦 5. Code Node: \"Generate .json File\"\n\nInstruction: This node converts the workflow JSON into a properly formatted binary file (.json) to upload to Google Drive. It uses the workflow name for the filename and sets the correct MIME type.\n\n* [See the Code node documentation.](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.code/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.code)"
      },
      "typeVersion": 1
    },
    {
      "id": "1b9ef445-9385-4b2c-a0c0-391bb5799887",
      "name": "Eliminar un flujo de trabajo",
      "type": "n8n-nodes-base.n8n",
      "position": [
        1568,
        80
      ],
      "parameters": {
        "operation": "delete",
        "workflowId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Get a Workflow').item.json.id }}"
        },
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "id": "VSxAuLMW3kDlXjYA",
          "name": "EMPTY"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5d540bb7-99f0-4202-8eb7-d37200468163",
      "name": "Obtener un flujo de trabajo",
      "type": "n8n-nodes-base.n8n",
      "position": [
        400,
        80
      ],
      "parameters": {
        "operation": "get",
        "workflowId": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $json['Paste the full workflow URL below.'] }}"
        },
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "id": "VSxAuLMW3kDlXjYA",
          "name": "EMPTY"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2da4e84a-20f3-4d3c-905e-eb884218e3b1",
      "name": "JSON a archivo",
      "type": "n8n-nodes-base.code",
      "position": [
        784,
        80
      ],
      "parameters": {
        "jsCode": "const fileName = `${$json.name.replace(/[^a-z0-9_-]/gi, \"_\") || \"workflow\"}.json`;\nconst jsonContent = JSON.stringify($json, null, 2);\n\nreturn [\n  {\n    binary: {\n      data: await this.helpers.prepareBinaryData(Buffer.from(jsonContent), fileName, 'application/json'),\n    },\n    json: {\n      fileName,\n    },\n  },\n];\n"
      },
      "typeVersion": 2
    }
  ],
  "pinData": {},
  "connections": {
    "2da4e84a-20f3-4d3c-905e-eb884218e3b1": {
      "main": [
        [
          {
            "node": "cbef6523-6186-4a83-b70c-5b3c4a619615",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5d540bb7-99f0-4202-8eb7-d37200468163": {
      "main": [
        [
          {
            "node": "2da4e84a-20f3-4d3c-905e-eb884218e3b1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "cbef6523-6186-4a83-b70c-5b3c4a619615": {
      "main": [
        [
          {
            "node": "1b9ef445-9385-4b2c-a0c0-391bb5799887",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1b9ef445-9385-4b2c-a0c0-391bb5799887": {
      "main": [
        [
          {
            "node": "10ef7ab2-86ca-4e62-b94f-77a6e18f920d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "76cdbf3e-e25b-4998-bf56-6cd13140e166": {
      "main": [
        [
          {
            "node": "5d540bb7-99f0-4202-8eb7-d37200468163",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Preguntas frecuentes

¿Cómo usar este flujo de trabajo?

Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.

¿En qué escenarios es adecuado este flujo de trabajo?

Intermedio - DevOps

¿Es de pago?

Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.

Información del flujo de trabajo
Nivel de dificultad
Intermedio
Número de nodos13
Categoría1
Tipos de nodos6
Descripción de la dificultad

Adecuado para usuarios con experiencia intermedia, flujos de trabajo de complejidad media con 6-15 nodos

Autor
Arlin Perez

Arlin Perez

@arlindeveloper

👋 Hi! I'm Arlin - a QA Engineer with 2 years of experience and a background in Dart & Flutter for mobile app development. ⚙️ I'm passionate about automation and love building efficient workflows using n8n. 📬 Reach out for any help with custom workflows

Enlaces externos
Ver en n8n.io

Compartir este flujo de trabajo

Categorías

Categorías: 34