Google Drive、GitHub、メッセージ アラートを使用した自動作業フロー バックアップシステム

上級

これはContent Creation, Multimodal AI分野の自動化ワークフローで、20個のノードを含みます。主にIf, N8n, Set, Code, Mergeなどのノードを使用。 Google Drive、GitHub、そしてメッセージアラートを使用した自動化ワークフローバックアップシステム

前提条件
  • GitHub Personal Access Token
  • Discord Bot Token または Webhook
  • Telegram Bot Token
  • Google Drive API認証情報
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "meta": {
    "instanceId": "c2650793f644091dc80fb900fe63448ad1f4b774008de9608064d67294f8307c",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "d6f2026a-4e1e-4067-b150-8a8cd5b6726d",
      "name": "手動トリガー",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -2016,
        576
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "85bccad1-b418-479b-95e3-b59d788a1093",
      "name": "設定",
      "type": "n8n-nodes-base.set",
      "position": [
        -1792,
        672
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "repo_owner",
              "name": "repo_owner",
              "type": "string",
              "value": "khmuhtadin"
            },
            {
              "id": "repo_name",
              "name": "repo_name",
              "type": "string",
              "value": "n8n-backup"
            },
            {
              "id": "repo_path",
              "name": "repo_path",
              "type": "string",
              "value": "n8n-backup/"
            },
            {
              "id": "gdrive_folder_id",
              "name": "gdrive_folder_id",
              "type": "string",
              "value": "124XMTeN20Huad4vYkTsiGBwildi4Ea9x"
            },
            {
              "id": "backup_timestamp",
              "name": "backup_timestamp",
              "type": "string",
              "value": "={{ $now.format('yyyy-MM-dd_HH-mm-ss') }}"
            },
            {
              "id": "backup_folder_name",
              "name": "backup_folder_name",
              "type": "string",
              "value": "=wfBackup - {{ $now.format('yyyy-MM-dd_HH-mm-ss') }}"
            },
            {
              "id": "a27de573-1591-4afa-97e5-e38d7b4e9839",
              "name": "telegram_chat_id",
              "type": "number",
              "value": 621412350
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5612fac5-9a76-4f04-a1ab-ca7b36d65742",
      "name": "GDriveフォルダ作成",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -1568,
        672
      ],
      "parameters": {
        "name": "={{ $json.backup_folder_name }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.gdrive_folder_id }}"
        },
        "resource": "folder"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "nTWGelaHlbvHrG66",
          "name": "Khaisa Studio"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "ba92f30e-c74b-4902-9406-d1e47410b8a3",
      "name": "全ワークフロー取得",
      "type": "n8n-nodes-base.n8n",
      "position": [
        -1344,
        672
      ],
      "parameters": {
        "filters": {},
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "id": "pSE0NDiUNmtDaZ5J",
          "name": "khmuhtadin"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "77790a4b-8144-47c2-9016-a421b9b7d4a1",
      "name": "ワークフーループ処理",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -1120,
        672
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "e93f44ca-c46c-4af8-b291-4beea32ce7ce",
      "name": "JSON ファイルへ変換",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        -896,
        288
      ],
      "parameters": {
        "options": {
          "format": true,
          "fileName": "={{ $json.name }}.json"
        },
        "operation": "toJson"
      },
      "typeVersion": 1.1
    },
    {
      "id": "c4362690-ceb3-4c7b-aefd-96a917be43c3",
      "name": "GitHub データ準備",
      "type": "n8n-nodes-base.code",
      "position": [
        -672,
        384
      ],
      "parameters": {
        "jsCode": "// Get workflow data from the Loop Over Workflows node\nconst workflow = $('Loop Over Workflows').item.json;\nconst config = $('Config').first().json;\n\n// Prepare GitHub path using workflow name instead of ID\nconst date = new Date();\nconst year = date.getFullYear();\nconst month = String(date.getMonth() + 1).padStart(2, '0');\n\n// Sanitize workflow name for use as filename\n// Remove special characters and replace spaces with underscores\nconst sanitizedName = workflow.name\n  .replace(/[^a-zA-Z0-9\\s-_]/g, '') // Remove special characters except spaces, hyphens, underscores\n  .replace(/\\s+/g, '_')              // Replace spaces with underscores\n  .replace(/_+/g, '_')               // Remove multiple underscores\n  .trim();                           // Remove leading/trailing spaces\n\n// Create the GitHub path with sanitized name\nconst githubPath = `${config.repo_path}${year}/${month}/${sanitizedName}.json`;\n\n// Order JSON keys for consistency\nconst orderJsonKeys = (jsonObj) => {\n  const ordered = {};\n  Object.keys(jsonObj).sort().forEach(key => {\n    ordered[key] = jsonObj[key];\n  });\n  return ordered;\n};\n\n// Prepare workflow data\nconst orderedWorkflow = orderJsonKeys(workflow);\nconst workflowJson = JSON.stringify(orderedWorkflow, null, 2);\n\n// Return both the original data and GitHub-specific data\nreturn {\n  ...workflow,\n  github_path: githubPath,\n  workflow_json: workflowJson,\n  year: year,\n  month: month,\n  sanitized_name: sanitizedName\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "24f1655a-bcab-4034-8a55-3bf436c1c32c",
      "name": "Google Driveへアップロード",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        0,
        96
      ],
      "parameters": {
        "name": "={{ $('Loop Over Workflows').item.json.name }}.json",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create GDrive Folder').item.json.id }}"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "nTWGelaHlbvHrG66",
          "name": "Khaisa Studio"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "a2380ef2-20ab-4d6d-adab-c2ca130e40ac",
      "name": "ファイル存在確認",
      "type": "n8n-nodes-base.github",
      "position": [
        -448,
        384
      ],
      "webhookId": "8987819b-d306-48c8-bd8d-58eac1610c75",
      "parameters": {
        "owner": {
          "__rl": true,
          "mode": "expression",
          "value": "={{ $('Config').item.json.repo_owner }}"
        },
        "filePath": "={{ $('Prepare GitHub Data').item.json.github_path }}",
        "resource": "file",
        "operation": "get",
        "repository": {
          "__rl": true,
          "mode": "expression",
          "value": "={{ $('Config').item.json.repo_name }}"
        },
        "authentication": "oAuth2",
        "asBinaryProperty": false,
        "additionalParameters": {}
      },
      "credentials": {
        "githubOAuth2Api": {
          "id": "WlWFMqmgPWeyIthW",
          "name": "khmuhtadin"
        }
      },
      "typeVersion": 1,
      "continueOnFail": true,
      "alwaysOutputData": true
    },
    {
      "id": "87c2b084-0755-4f80-b768-619fc97d03f6",
      "name": "ファイル存在?",
      "type": "n8n-nodes-base.if",
      "position": [
        -224,
        384
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "has-content",
              "operator": {
                "type": "string",
                "operation": "exists"
              },
              "leftValue": "={{ $json.content }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "683d43dc-3511-4dbb-bdd8-649bd57cd122",
      "name": "GitHub ファイル更新",
      "type": "n8n-nodes-base.github",
      "onError": "continueRegularOutput",
      "position": [
        0,
        288
      ],
      "webhookId": "d3e6f63d-a808-40cf-8f71-6e6b7fb1a4e5",
      "parameters": {
        "owner": {
          "__rl": true,
          "mode": "expression",
          "value": "={{ $('Config').item.json.repo_owner }}"
        },
        "filePath": "={{ $('Prepare GitHub Data').item.json.github_path }}",
        "resource": "file",
        "operation": "edit",
        "repository": {
          "__rl": true,
          "mode": "expression",
          "value": "={{ $('Config').item.json.repo_name }}"
        },
        "fileContent": "={{ $('Prepare GitHub Data').item.json.workflow_json }}",
        "commitMessage": "=Update: {{ $('Loop Over Workflows').item.json.name }} - {{ $('Config').item.json.backup_timestamp }}",
        "authentication": "oAuth2"
      },
      "credentials": {
        "githubOAuth2Api": {
          "id": "WlWFMqmgPWeyIthW",
          "name": "khmuhtadin"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "486829d1-c66d-4b0f-9038-1c8f98a42f65",
      "name": "GitHub ファイル作成",
      "type": "n8n-nodes-base.github",
      "position": [
        0,
        576
      ],
      "webhookId": "15aff88f-3b60-4232-adcd-b1ddbcc22794",
      "parameters": {
        "owner": {
          "__rl": true,
          "mode": "expression",
          "value": "={{ $('Config').item.json.repo_owner }}"
        },
        "filePath": "={{ $('Prepare GitHub Data').item.json.github_path }}",
        "resource": "file",
        "repository": {
          "__rl": true,
          "mode": "expression",
          "value": "={{ $('Config').item.json.repo_name }}"
        },
        "fileContent": "={{ $('Prepare GitHub Data').item.json.workflow_json }}",
        "commitMessage": "=Create: {{ $('Loop Over Workflows').item.json.name }} - {{ $('Config').item.json.backup_timestamp }}",
        "authentication": "oAuth2"
      },
      "credentials": {
        "githubOAuth2Api": {
          "id": "WlWFMqmgPWeyIthW",
          "name": "khmuhtadin"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7b40e9a2-c182-4b60-84a8-ff468e9a3b24",
      "name": "GitHub 結果統合",
      "type": "n8n-nodes-base.merge",
      "position": [
        224,
        288
      ],
      "parameters": {},
      "typeVersion": 3
    },
    {
      "id": "d478e490-bbbe-4b12-a20a-305ebdafde70",
      "name": "完了マーク",
      "type": "n8n-nodes-base.set",
      "position": [
        448,
        656
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "backup_complete",
              "name": "backup_complete",
              "type": "boolean",
              "value": true
            },
            {
              "id": "workflow_name",
              "name": "workflow_name",
              "type": "string",
              "value": "={{ $('Loop Over Workflows').item.json.name }}"
            },
            {
              "id": "workflow_id",
              "name": "workflow_id",
              "type": "string",
              "value": "={{ $('Loop Over Workflows').item.json.id }}"
            },
            {
              "id": "gdrive_backup",
              "name": "gdrive_backup",
              "type": "boolean",
              "value": true
            },
            {
              "id": "github_backup",
              "name": "github_backup",
              "type": "boolean",
              "value": true
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b0325d2f-51c6-4147-b1fc-e336d26e4a78",
      "name": "最終サマリー",
      "type": "n8n-nodes-base.set",
      "position": [
        -896,
        672
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "total_workflows",
              "name": "total_workflows",
              "type": "number",
              "value": "={{ $('Get All Workflows').all().length }}"
            },
            {
              "id": "backup_timestamp",
              "name": "backup_timestamp",
              "type": "string",
              "value": "={{ $('Config').first().json.backup_timestamp }}"
            },
            {
              "id": "gdrive_folder",
              "name": "gdrive_folder",
              "type": "string",
              "value": "={{ $('Create GDrive Folder').first().json.name }}"
            },
            {
              "id": "status",
              "name": "status",
              "type": "string",
              "value": "Backup completed successfully"
            }
          ]
        }
      },
      "executeOnce": true,
      "typeVersion": 3.4
    },
    {
      "id": "6aa32c53-f0e5-44a4-9a4c-0a785575f661",
      "name": "通知: Discord",
      "type": "n8n-nodes-base.discord",
      "position": [
        -672,
        768
      ],
      "webhookId": "cc8e8a13-3f8f-4d81-848d-770fbd16f26d",
      "parameters": {
        "content": "={{ $json.status }}\n\nTotal workflow: {{ $json.total_workflows }}\nTimestamp: {{ $json.backup_timestamp }}\nDrive Folder: {{ $json.gdrive_folder }}\nRepo Name: {{ $('Config').item.json.repo_name }}",
        "guildId": {
          "__rl": true,
          "mode": "list",
          "value": "924339263372406844",
          "cachedResultUrl": "https://discord.com/channels/924339263372406844",
          "cachedResultName": "Khaisa Studio"
        },
        "options": {},
        "resource": "message",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "1418253548193447936",
          "cachedResultUrl": "https://discord.com/channels/924339263372406844/1418253548193447936",
          "cachedResultName": "monitoring"
        }
      },
      "credentials": {
        "discordBotApi": {
          "id": "dJMKbc7ZDni2mvkT",
          "name": "Khaisa-n8n-bot"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "bde9e6db-95e5-4b36-8ee2-9b3489816c7e",
      "name": "通知: Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -672,
        576
      ],
      "webhookId": "bb4dfcba-1411-4242-9302-b23a369fc4a7",
      "parameters": {
        "text": "=<b>✅ Backup Status:</b> {{ $json.status }}<br>\n<b>Total Workflows:</b> {{ $json.total_workflows }}<br>\n<b>Timestamp:</b> {{ $json.backup_timestamp }}<br>\n<b>Drive Folder:</b> {{ $json.gdrive_folder }}<br>\n<b>Repo Name:</b> {{ $('Config').item.json.repo_name }}<br><br>\n<i>Your n8n backup has been completed successfully!</i>",
        "chatId": "={{ $('Config').item.json.telegram_chat_id }}",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "wlH3um2hoPAGI8XX",
          "name": "Khaisa Dev Bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d8638508-4230-4384-8202-7e7a15fd2852",
      "name": "12時間毎スケジュール",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -2016,
        768
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 12
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "71b29f3d-cf30-4f71-86dc-bee8fc18c2d8",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1792,
        896
      ],
      "parameters": {
        "color": 5,
        "width": 448,
        "height": 640,
        "content": "## 🚀 n8n Workflow Backup System\n\n### 📋 Requirements\n- **n8n API Credentials** - For fetching workflows\n- **Google Drive OAuth2** - For cloud backup storage  \n- **GitHub OAuth2** - For version control backup\n- **Telegram Bot API** (Optional) - For notifications\n- **Discord Bot API** (Optional) - For notifications\n\n### 🔗 Resource URLs\n- **n8n API**: [docs.n8n.io/api](https://docs.n8n.io/api/)\n- **Google Drive API**: [console.cloud.google.com](https://console.cloud.google.com/)\n- **GitHub OAuth**: [github.com/settings/developers](https://github.com/settings/developers)\n- **Telegram Bot**: [@BotFather](https://t.me/botfather)\n- **Discord Bot**: [discord.com/developers](https://discord.com/developers/applications)\n\n### ✨ Features\n- Dual backup (Google Drive + GitHub)\n- Version control with Git history\n- Sanitized filenames (removes special characters)\n- Error handling with fallback\n- Optional notifications on completion\n- Runs automatically twice daily"
      },
      "typeVersion": 1
    },
    {
      "id": "7672fb85-001c-48e5-8181-b48175e45b5a",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1312,
        896
      ],
      "parameters": {
        "color": 5,
        "width": 448,
        "height": 640,
        "content": "## ⚙️ Configuration\nEdit the **Config** node with your settings:\n- `repo_owner` - Your GitHub username\n- `repo_name` - Repository name for backups\n- `repo_path` - Folder path in repo (e.g., \"n8n-backup/\")\n- `gdrive_folder_id` - Google Drive parent folder ID\n- `telegram_chat_id` - Your Telegram chat ID (optional)\n\n### 📊 Workflow Process\n\n1. **Trigger** → Manual or scheduled every 12 hours\n2. **Setup** → Creates timestamped backup folder in Google Drive\n3. **Fetch** → Gets all workflows from n8n instance\n4. **Loop Process** → For each workflow:\n   - Converts to formatted JSON file\n   - Uploads to Google Drive folder\n   - Checks if file exists on GitHub\n   - Creates new or updates existing GitHub file\n5. **Complete** → Sends summary notifications to Telegram & Discord\n\n### 📁 Backup Structure\n- **Google Drive**: `/wfBackup - YYYY-MM-DD_HH-mm-ss/workflow_name.json`\n- **GitHub**: `/n8n-backup/YYYY/MM/workflow_name.json`\n\n"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "85bccad1-b418-479b-95e3-b59d788a1093": {
      "main": [
        [
          {
            "node": "5612fac5-9a76-4f04-a1ab-ca7b36d65742",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "87c2b084-0755-4f80-b768-619fc97d03f6": {
      "main": [
        [
          {
            "node": "683d43dc-3511-4dbb-bdd8-649bd57cd122",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "486829d1-c66d-4b0f-9038-1c8f98a42f65",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b0325d2f-51c6-4147-b1fc-e336d26e4a78": {
      "main": [
        [
          {
            "node": "bde9e6db-95e5-4b36-8ee2-9b3489816c7e",
            "type": "main",
            "index": 0
          },
          {
            "node": "6aa32c53-f0e5-44a4-9a4c-0a785575f661",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d478e490-bbbe-4b12-a20a-305ebdafde70": {
      "main": [
        [
          {
            "node": "77790a4b-8144-47c2-9016-a421b9b7d4a1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d6f2026a-4e1e-4067-b150-8a8cd5b6726d": {
      "main": [
        [
          {
            "node": "85bccad1-b418-479b-95e3-b59d788a1093",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ba92f30e-c74b-4902-9406-d1e47410b8a3": {
      "main": [
        [
          {
            "node": "77790a4b-8144-47c2-9016-a421b9b7d4a1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "486829d1-c66d-4b0f-9038-1c8f98a42f65": {
      "main": [
        [
          {
            "node": "7b40e9a2-c182-4b60-84a8-ff468e9a3b24",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "683d43dc-3511-4dbb-bdd8-649bd57cd122": {
      "main": [
        [
          {
            "node": "7b40e9a2-c182-4b60-84a8-ff468e9a3b24",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "77790a4b-8144-47c2-9016-a421b9b7d4a1": {
      "main": [
        [
          {
            "node": "b0325d2f-51c6-4147-b1fc-e336d26e4a78",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "e93f44ca-c46c-4af8-b291-4beea32ce7ce",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c4362690-ceb3-4c7b-aefd-96a917be43c3": {
      "main": [
        [
          {
            "node": "a2380ef2-20ab-4d6d-adab-c2ca130e40ac",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a2380ef2-20ab-4d6d-adab-c2ca130e40ac": {
      "main": [
        [
          {
            "node": "87c2b084-0755-4f80-b768-619fc97d03f6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e93f44ca-c46c-4af8-b291-4beea32ce7ce": {
      "main": [
        [
          {
            "node": "24f1655a-bcab-4034-8a55-3bf436c1c32c",
            "type": "main",
            "index": 0
          },
          {
            "node": "c4362690-ceb3-4c7b-aefd-96a917be43c3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5612fac5-9a76-4f04-a1ab-ca7b36d65742": {
      "main": [
        [
          {
            "node": "ba92f30e-c74b-4902-9406-d1e47410b8a3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7b40e9a2-c182-4b60-84a8-ff468e9a3b24": {
      "main": [
        [
          {
            "node": "d478e490-bbbe-4b12-a20a-305ebdafde70",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "24f1655a-bcab-4034-8a55-3bf436c1c32c": {
      "main": [
        [
          {
            "node": "7b40e9a2-c182-4b60-84a8-ff468e9a3b24",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "d8638508-4230-4384-8202-7e7a15fd2852": {
      "main": [
        [
          {
            "node": "85bccad1-b418-479b-95e3-b59d788a1093",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

このワークフローの使い方は?

上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。

このワークフローはどんな場面に適していますか?

上級 - コンテンツ作成, マルチモーダルAI

有料ですか?

このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。

ワークフロー情報
難易度
上級
ノード数20
カテゴリー2
ノードタイプ14
難易度説明

上級者向け、16ノード以上の複雑なワークフロー

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34