8
n8n 中文网amn8n.com

AIAutomationPro 备份凭据到 Google Drive

中级

这是一个DevOps, IT Ops领域的自动化工作流,包含 9 个节点。主要使用 Code, Aggregate, GoogleDrive, ConvertToFile, ManualTrigger 等节点。 自动化 n8n 凭据备份至 Google Drive,含定时执行

前置要求
  • Google Drive API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "a0wJocTNabVjrlee",
  "meta": {
    "instanceId": "b3df22d2875c82e3ba1883c50049ed9cee0bcabf99d2b486961d2245a09e3964",
    "templateCredsSetupCompleted": true
  },
  "name": "AIAutomationPro 备份凭据到 Google Drive",
  "tags": [],
  "nodes": [
    {
      "id": "550155aa-dfd0-4bbe-b3c7-26891c1903dd",
      "name": "点击触发器",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        60,
        280
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "000cbe87-24bb-41a2-a6db-4dc12529b191",
      "name": "执行命令获取所有凭据",
      "type": "n8n-nodes-base.executeCommand",
      "position": [
        520,
        280
      ],
      "parameters": {
        "command": "npx n8n export:credentials --all --decrypted"
      },
      "typeVersion": 1
    },
    {
      "id": "1d6c568b-1bbd-458c-b5c9-d209a6cc44e5",
      "name": "JSON 格式化数据",
      "type": "n8n-nodes-base.code",
      "position": [
        720,
        280
      ],
      "parameters": {
        "jsCode": "// Function to beautify JSON\nfunction beautifyJson(jsonString) {\n  try {\n    // Parse the JSON string\n    const jsonObject = JSON.parse(jsonString);\n\n    // Format the JSON with indentation\n    return jsonObject; // Return the parsed object directly\n  } catch (error) {\n    // Return the error message if JSON is invalid\n    return `Invalid JSON: ${error.message}`;\n  }\n}\n\n// Retrieve the JSON object from the input data\nconst input = $input.all()[0].json;\n\n// Extract the JSON string from the stdout field\nconst jsonString = input.stdout.match(/\\[{.*}\\]/s);\n\n// Check if a valid JSON string is found\nif (!jsonString) {\n  return {\n    json: {\n      error: \"No valid JSON string found in stdout.\"\n    }\n  };\n}\n\n// Beautify the JSON\nconst beautifiedJson = beautifyJson(jsonString[0]);\n\n// Output the beautified JSON, ensuring each entry is in an object with a 'json' key\nconst output = beautifiedJson.map(entry => ({ json: entry }));\n\n// Return the output\nreturn output;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "2c41e6b0-b1c2-4102-a37f-403b5438caf3",
      "name": "聚合凭据",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        920,
        280
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "d6a08fd5-16c6-4746-ab23-9dd956eda393",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        420,
        200
      ],
      "parameters": {
        "width": 911,
        "height": 292,
        "content": "## 从 N8n 导出所有凭据"
      },
      "typeVersion": 1
    },
    {
      "id": "458c133d-ce5e-4fc5-9af5-79b04e86a18d",
      "name": "转换为文件",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        1120,
        280
      ],
      "parameters": {
        "options": {},
        "operation": "toJson",
        "binaryPropertyName": "=data"
      },
      "typeVersion": 1.1
    },
    {
      "id": "0e39d74f-53ee-4b9e-b213-97bfaa605e78",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        200
      ],
      "parameters": {
        "width": 311,
        "height": 292,
        "content": "## Google Drive 文件夹"
      },
      "typeVersion": 1
    },
    {
      "id": "afd3b1ce-bd9e-4dda-bb9a-d27f343f57a1",
      "name": "Google Drive 上传文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1540,
        280
      ],
      "parameters": {
        "name": "=n8n_backup_credentials.json",
        "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": "1p447S9MWYcRpA6dmfDe-Kdc3-d8L2Lzr",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1p447S9MWYcRpA6dmfDe-Kdc3-d8L2Lzr",
          "cachedResultName": "Tung Backup Credential"
        },
        "inputDataFieldName": "=data"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "q8OibtSjVurZl2tb",
          "name": "AI Auto Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "62a9e8c8-9731-459b-98c7-9befaf4c7cce",
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        60,
        480
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "35978b6b-b4a2-4fce-a3bf-3ecf1f6c3e55",
  "connections": {
    "Convert To File": {
      "main": [
        [
          {
            "node": "Google Drive Upload File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On Click Trigger": {
      "main": [
        [
          {
            "node": "Execute Command Get All Cridentials",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Execute Command Get All Cridentials",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JSON Formatting Data": {
      "main": [
        [
          {
            "node": "Aggregate Cridentials",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Cridentials": {
      "main": [
        [
          {
            "node": "Convert To File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Command Get All Cridentials": {
      "main": [
        [
          {
            "node": "JSON Formatting Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 开发运维, IT 运维

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量9
分类2
节点类型8
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Daniel Ng

Daniel Ng

@danielng

A Growth Hacker, Digital Marketer & AI Automation Builder with 10+ years of experience in Digital Marketing & Workflow Automation. Based in Helsinki, Finland. For questions about my templates and customization, contact me at: daniel@aiautomationpro.org

外部链接
在 n8n.io 查看

分享此工作流